:root {
  --brand: #0f5b63;
  --brand-dark: #0a3f45;
  --bg: #f5f7f8;
  --card: #ffffff;
  --text: #163036;
  --muted: #5f7175;
  --line: #dbe4e6;
  --red: #d9534f;
  --amber: #f0ad4e;
  --green: #5cb85c;
  --shadow: 0 8px 24px rgba(16,40,45,.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── HEADER ── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: var(--shadow);
}
.app-header .brand-text h1 { margin: 0; font-size: 1.35rem; }
.app-header .brand-text p  { margin: .15rem 0 0; opacity: .92; font-size: .9rem; }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.15);
  border-radius: 999px; padding: 5px 12px 5px 5px;
  font-size: .85rem;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; letter-spacing: .5px;
}
.badge-dot {
  display: inline-block;
  background: var(--amber); color: #163036;
  border-radius: 999px; padding: 2px 7px;
  font-size: .75rem; font-weight: 700; margin-left: 4px;
}

/* ── LAYOUT ── */
.container { max-width: 1100px; margin: 0 auto; padding: 14px; }

/* ── CARD ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--brand-dark); }

/* ── GRID ── */
.grid   { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── FORMS ── */
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .92rem; font-weight: 600;
}
input, select, textarea {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); font-size: .95rem;
  font-family: Arial, Helvetica, sans-serif;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,91,99,.1);
}
textarea { min-height: 72px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
select option { background: #fff; }

/* ── BUTTONS ── */
button {
  border: none; border-radius: 12px; padding: 11px 16px;
  cursor: pointer; font-weight: 700; font-size: .9rem;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--brand); color: #fff;
  transition: background .15s, transform .1s;
}
button:hover  { background: var(--brand-dark); }
button:active { transform: scale(.98); }
button.secondary { background: #eaf2f3; color: var(--brand-dark); }
button.secondary:hover { background: #d4e8ea; }
button.ghost   { background: transparent; color: var(--brand); padding: 8px 12px; }
button.ghost:hover { background: #eaf2f3; }
button.danger  { background: var(--red); color: #fff; }
button.danger:hover { background: #b52b27; }
button.success { background: var(--green); color: #fff; }
button.success:hover { background: #449d44; }
button.sm { padding: 7px 12px; font-size: .82rem; }
button.hidden { display: none; }
.file-btn {
  border-radius: 12px; padding: 11px 16px;
  cursor: pointer; font-weight: 700; font-size: .9rem;
  background: #eaf2f3; color: var(--brand-dark);
  display: inline-block;
}

/* ── TOOLBAR ── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ── TABS ── */
.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px;
}
.tab { background: #eaf2f3; color: var(--brand-dark); }
.tab.active { background: var(--brand); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── AUTH SCREENS ── */
.auth-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eaf2f3 0%, #f5f7f8 100%);
  padding: 20px;
}
.auth-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px 32px;
  width: 100%; max-width: 420px;
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.auth-logo .lodge-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; border-radius: 14px; padding: 10px 18px;
  font-size: 1.1rem; font-weight: 700; margin-bottom: 10px;
}
.auth-logo h2 { margin: 0; font-size: 1.3rem; color: var(--brand-dark); }
.auth-logo p  { margin: 4px 0 0; font-size: .88rem; color: var(--muted); }
.auth-card .grid { margin-bottom: 0; }
.auth-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.error-msg { color: var(--red); font-size: .85rem; margin-top: 6px; text-align: center; }

/* ── PENDING SCREEN ── */
.pending-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: #fff9ef; border: 2px solid var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 16px;
}

/* ── STAT CARDS ── */
.metric {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; background: #fbfdfd;
}
.metric .metric-label { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.metric strong { display: block; font-size: 1.5rem; color: var(--brand-dark); margin-top: 2px; }
.metric.accent-amber strong { color: #c87c00; }
.metric.accent-green  strong { color: #449d44; }
.metric.accent-red    strong { color: var(--red); }

/* ── STRIP CARDS (coloured) ── */
.strip-card {
  border-radius: 16px; padding: 14px; color: #fff; font-weight: 700;
}
.strip-card small { display: block; opacity: .9; margin-bottom: 6px; font-size: .8rem; }
.strip-card .big  { font-size: 1.4rem; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: middle; }
th { background: #f8fbfb; text-align: left; font-size: .83rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: #f8fbfb; }
tr:last-child td { border-bottom: none; }
.totals-row td { background: #f0f7f8; font-weight: 700; color: var(--brand-dark); border-top: 2px solid var(--line); }

/* ── STATUS PILLS ── */
.status-pill {
  display: inline-block; padding: 4px 10px;
  border-radius: 999px; font-weight: 700; font-size: .78rem;
}
.pill-pending  { background: #fff3cd; color: #856404; }
.pill-approved { background: #d4edda; color: #155724; }
.pill-rejected { background: #f8d7da; color: #721c24; }

/* ── PO NUMBER ── */
.po-no {
  font-family: 'Courier New', monospace;
  background: #eaf2f3; color: var(--brand-dark);
  border-radius: 8px; padding: 3px 10px; font-size: .85rem;
  font-weight: 700;
}

/* ── SECTION HEADER ── */
.section-header {
  display: flex; justify-content: space-between;
  align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.small { font-size: .85rem; color: var(--muted); }

/* ── SEARCH ROW ── */
.search-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search-row input  { flex: 1; min-width: 180px; }
.search-row select { width: auto; min-width: 140px; }

/* ── ITEMS TABLE ── */
.items-table th, .items-table td { padding: 8px; }
.items-table input { padding: 8px 10px; font-size: .9rem; }
.del-btn { background: none; border: none; color: var(--red); cursor: pointer; font-size: 1.2rem; padding: 4px 8px; border-radius: 8px; }
.del-btn:hover { background: #f8d7da; }
.add-row-btn {
  width: 100%; padding: 10px; margin-top: 8px;
  background: transparent; border: 1.5px dashed var(--line); border-radius: 12px;
  color: var(--brand); cursor: pointer; font-weight: 600; font-size: .9rem;
  transition: background .15s; font-family: Arial, Helvetica, sans-serif;
}
.add-row-btn:hover { background: #eaf2f3; }

/* ── SUGGESTIONS ── */
.input-wrap { position: relative; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--line);
  border-top: none; border-radius: 0 0 12px 12px;
  max-height: 200px; overflow-y: auto;
  box-shadow: 0 8px 16px rgba(0,0,0,.1);
}
.suggestion-item {
  padding: 9px 14px; cursor: pointer; font-size: .9rem;
  border-bottom: 1px solid #f0f3f4;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #eaf2f3; }
.suggestion-item .sup-name { font-size: .78rem; color: var(--muted); margin-top: 1px; }

/* ── APPROVAL CARD ── */
.approval-item {
  border-left: 5px solid var(--amber);
  background: #fff9ef; border-radius: 12px;
  padding: 14px; margin-bottom: 10px;
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.approval-item .ainfo { flex: 1; min-width: 0; }
.approval-item .apo   { font-size: .8rem; color: var(--muted); margin-bottom: 3px; }
.approval-item .atitle { font-weight: 700; font-size: 1rem; margin-bottom: 3px; }
.approval-item .ameta  { font-size: .85rem; color: var(--muted); }
.approval-item .aamount { font-size: 1.4rem; font-weight: 700; color: var(--brand-dark); white-space: nowrap; }
.approval-actions { display: flex; gap: 8px; flex-direction: column; align-items: flex-end; }

/* ── NOTICE ── */
.notice {
  padding: 12px; border-radius: 14px;
  background: #eef7f7; color: var(--brand-dark); margin: 10px 0;
  font-size: .9rem;
}
.notice.warn { background: #fff9ef; }
.notice.err  { background: #f8d7da; color: #721c24; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16,40,45,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 660px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(16,40,45,.25);
  transform: translateY(12px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--radius) var(--radius) 0 0; color: #fff;
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}
.close-btn { background: rgba(255,255,255,.2); color: #fff; padding: 5px 10px; font-size: 1rem; border-radius: 8px; }
.close-btn:hover { background: rgba(255,255,255,.3); }

/* ── DETAIL FIELD ── */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.df {
  background: #f8fbfb; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.df .df-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.df .df-val   { font-size: .95rem; font-weight: 600; color: var(--text); }

/* ── PRODUCT GRID ── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.product-card {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; cursor: pointer; background: #fbfdfd;
  transition: border-color .15s, box-shadow .15s;
}
.product-card:hover { border-color: var(--brand); box-shadow: 0 4px 16px rgba(15,91,99,.1); }
.product-card .pname { font-weight: 700; font-size: .92rem; margin-bottom: 3px; }
.product-card .psup  { font-size: .8rem; color: var(--muted); }
.product-card .pcount { font-size: .8rem; color: var(--brand); margin-top: 6px; font-weight: 700; }

/* ── TIMELINE ── */
.tl-item { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-start; }
.tl-dot  { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex-shrink: 0; }
.tl-title { font-size: .9rem; font-weight: 600; }
.tl-sub   { font-size: .8rem; color: var(--muted); margin-top: 1px; }

/* ── NOTIFICATION ── */
.notif {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 18px; font-size: .9rem;
  box-shadow: var(--shadow); max-width: 300px;
  transform: translateX(120%); transition: transform .3s ease;
}
.notif.show { transform: translateX(0); }
.notif.n-success { border-left: 4px solid var(--green); }
.notif.n-error   { border-left: 4px solid var(--red); }
.notif.n-warn    { border-left: 4px solid var(--amber); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty .empty-icon { font-size: 42px; margin-bottom: 12px; }
.empty h3 { font-size: 1.1rem; color: var(--text); margin: 0 0 6px; }

/* ── PRINT ── */
@media print {
  .app-header, .tabs, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── RESPONSIVE ── */
@media (max-width: 780px) {
  .grid-2, .grid-3, .grid-4, .detail-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .tabs { grid-template-columns: repeat(3, 1fr); }
  .approval-item { flex-direction: column; }
  .approval-actions { flex-direction: row; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}
@media (max-width: 500px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: 1fr; }
}
