/* ========================================================================
   Procut-CNC Customer Portal
   Layered on top of site.css — portal-specific UI shell
   ======================================================================== */

:root {
  --sidebar-w: 256px;
  --topbar-h: 60px;
}

/* App shell ============================================================= */
body.portal {
  background: var(--paper);
  color: var(--ink);
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
}
@media (max-width: 1023px) {
  .portal-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .portal-sidebar { display: none; position: fixed; top: 0; bottom: 0; left: 0; width: 280px; z-index: 70; }
  .portal-sidebar.open { display: flex; }
  .portal-backdrop { position: fixed; inset: 0; background: rgba(6,16,28,.5); z-index: 65; display: none; }
  .portal-backdrop.open { display: block; }
}

/* Sidebar ============================================================= */
.portal-sidebar {
  grid-area: sidebar;
  background: var(--steel-1000);
  color: var(--steel-100);
  border-right: 1px solid var(--steel-800);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.portal-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 0 1.1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--steel-800);
  color: #fff; font-weight: 700; letter-spacing: .08em;
  font-size: .9rem;
}
.portal-brand img { height: 28px; width: auto; }

.portal-nav { padding: 1rem .55rem; flex: 1; overflow-y: auto; }
.portal-nav h5 {
  font-size: .68rem; font-weight: 700;
  color: var(--steel-300); letter-spacing: .14em; text-transform: uppercase;
  padding: .9rem .65rem .5rem;
}
.portal-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem;
  border-radius: var(--r-sm);
  color: var(--steel-200);
  font-size: .9rem;
  margin: 1px 0;
  transition: all var(--t-fast);
  position: relative;
}
.portal-nav a:hover { background: var(--steel-900); color: #fff; }
.portal-nav a.active {
  background: var(--steel-900);
  color: #fff;
  font-weight: 600;
}
.portal-nav a.active::before {
  content: ""; position: absolute; left: -.55rem; top: 6px; bottom: 6px; width: 3px;
  background: var(--amber-500); border-radius: 0 2px 2px 0;
}
.portal-nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.portal-nav a.active svg { opacity: 1; color: var(--amber-400); }

.portal-badge {
  margin-left: auto;
  font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  background: var(--amber-500); color: var(--steel-1000);
}
.portal-badge.muted { background: var(--steel-800); color: var(--steel-200); }

.portal-sidebar-footer {
  padding: .9rem 1.1rem;
  border-top: 1px solid var(--steel-800);
  display: flex; align-items: center; gap: .65rem;
  font-size: .82rem;
  background: var(--steel-950);
}
.portal-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--grad-amber);
  color: var(--steel-1000); font-weight: 700;
  display: grid; place-items: center;
  font-size: .82rem; flex: none;
}
.portal-sidebar-footer strong { color: #fff; display: block; font-size: .85rem; }
.portal-sidebar-footer span { color: var(--steel-300); font-size: .72rem; }

/* Topbar ============================================================= */
.portal-topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
}

.portal-search {
  flex: 1; max-width: 480px;
  position: relative;
}
.portal-search input {
  width: 100%;
  padding: .55rem .8rem .55rem 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: .92rem;
}
.portal-search input:focus {
  outline: none; border-color: var(--amber-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
.portal-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); }

.portal-iconbtn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.portal-iconbtn:hover { background: var(--paper); color: var(--ink); }
.portal-iconbtn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber-500); border: 2px solid #fff;
}

.portal-mobiletoggle { display: none; }
@media (max-width: 1023px) {
  .portal-mobiletoggle { display: inline-flex; }
  .portal-search { max-width: none; }
}

/* Main ============================================================= */
.portal-main {
  grid-area: main;
  padding: 2rem 2rem 4rem;
  max-width: 1400px;
  width: 100%;
}
@media (max-width: 768px) {
  .portal-main { padding: 1.25rem 1rem 4rem; }
}

.portal-page-head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem;
}
.portal-page-head h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.25rem;
  letter-spacing: -.01em;
  margin: 0;
}
.portal-page-head p { color: var(--ink-3); margin-top: .25rem; }

/* Stat cards ============================================================= */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-1);
}
.stat-card .label { font-size: .75rem; color: var(--ink-4); letter-spacing: .08em; text-transform: uppercase; font-weight: 600; margin: 0; }
.stat-card .value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.25rem; font-weight: 700; line-height: 1;
  margin-top: .35rem;
  color: var(--ink);
}
.stat-card .delta { font-size: .82rem; margin-top: .35rem; color: var(--ink-3); }
.stat-card .delta.up { color: var(--signal-green); }
.stat-card .delta.down { color: var(--signal-red); }

/* Status badges ============================================================= */
.status-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status-badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.draft       { background: #f3f4f6; color: #4b5563; }
.status-badge.review      { background: rgba(245,158,11,.12); color: #b45309; }
.status-badge.quoted      { background: rgba(56,189,248,.12); color: #075985; }
.status-badge.accepted    { background: rgba(16,185,129,.12); color: #065f46; }
.status-badge.production  { background: rgba(245,158,11,.18); color: #92400e; }
.status-badge.fai         { background: rgba(168,85,247,.12); color: #6b21a8; }
.status-badge.shipped     { background: rgba(99,102,241,.12); color: #3730a3; }
.status-badge.complete    { background: rgba(16,185,129,.18); color: #064e3b; }
.status-badge.urgent      { background: rgba(239,68,68,.12); color: #991b1b; }

/* Tables ============================================================= */
.portal-table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.portal-table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.portal-table-head h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; margin: 0; }
.portal-table-filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.portal-filter {
  padding: .35rem .75rem;
  font-size: .8rem; font-weight: 500;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.portal-filter:hover { border-color: var(--steel-300); }
.portal-filter.active { background: var(--steel-1000); border-color: var(--steel-1000); color: #fff; }

.portal-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.portal-table th, .portal-table td { padding: .85rem 1.25rem; text-align: left; vertical-align: middle; }
.portal-table thead th {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 700;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.portal-table tbody tr { border-bottom: 1px solid var(--line); transition: background var(--t-fast); }
.portal-table tbody tr:last-child { border-bottom: 0; }
.portal-table tbody tr:hover { background: var(--paper); }
.portal-table .id { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--ink-2); font-size: .85rem; }
.portal-table .meta { color: var(--ink-4); font-size: .8rem; margin-top: 2px; }

/* Empty state ============================================================= */
.portal-empty {
  text-align: center; padding: 3.5rem 1rem;
  color: var(--ink-3);
}
.portal-empty .icon {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--paper-2);
  color: var(--ink-4);
}

/* Demo banner ============================================================= */
.portal-demo-banner {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  background: var(--steel-1000); color: var(--amber-400);
  font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; padding: .45rem 1rem;
  border-bottom: 1px solid var(--amber-700);
}

/* Document tile ============================================================= */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.doc-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.doc-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--steel-300); }
.doc-tile-thumb {
  aspect-ratio: 4/3; background: var(--steel-1000);
  display: grid; place-items: center;
  color: var(--amber-400);
  font-family: 'JetBrains Mono', monospace; font-size: .82rem;
  position: relative;
}
.doc-tile-type {
  position: absolute; top: .65rem; left: .65rem;
  padding: .15rem .5rem; font-size: .65rem; font-weight: 700;
  background: var(--amber-500); color: var(--steel-1000);
  border-radius: 3px; letter-spacing: .08em;
}
.doc-tile-body { padding: .85rem 1rem 1rem; }
.doc-tile-body h4 { font-size: .94rem; font-weight: 600; line-height: 1.3; margin: 0; color: var(--ink); }
.doc-tile-body .meta { color: var(--ink-4); font-size: .78rem; margin-top: .25rem; }

/* Auth screen ============================================================= */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
}
@media (max-width: 1023px) { .auth-page { grid-template-columns: 1fr; } .auth-photo { display: none; } }

.auth-photo {
  position: relative;
  background-size: cover;
  background-position: center;
  isolation: isolate;
  padding: 2rem;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
}
.auth-photo::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(6,16,28,.85) 0%, rgba(6,16,28,.6) 50%, rgba(6,16,28,.95) 100%),
    radial-gradient(60% 50% at 30% 30%, rgba(245,158,11,.2) 0%, rgba(245,158,11,0) 60%);
}

.auth-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.auth-form { width: 100%; max-width: 420px; }
.auth-form h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 2.4rem; line-height: 1.05; margin: 0; }
.auth-form p { color: var(--ink-3); margin-top: .5rem; }
.auth-form .field { margin-top: .4rem; }
.auth-form label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2); margin-top: 1rem; }

.auth-divider {
  display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0;
  font-size: .75rem; color: var(--ink-4); text-transform: uppercase; letter-spacing: .12em;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Misc ============================================================= */
.kv-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.kv-row:last-child { border-bottom: 0; }
.kv-row span:first-child { color: var(--ink-4); }
.kv-row span:last-child { color: var(--ink); font-weight: 500; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: 1.2rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.6rem; top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--line);
}
.timeline-item.done::before { border-color: var(--amber-500); background: var(--amber-500); }
.timeline-item.active::before { border-color: var(--amber-500); }
.timeline-item h4 { font-size: .94rem; font-weight: 600; margin: 0; }
.timeline-item p { font-size: .82rem; color: var(--ink-3); margin: .15rem 0 0; }
.timeline-item .when { font-size: .75rem; color: var(--ink-4); font-family: 'JetBrains Mono', monospace; }
