:root {
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --border: #dfe5ef;
  --panel: #ffffff;
  --teal: #0e7490;
  --teal-dark: #155e75;
  --navy: #1f2937;
  --accent: #8fc73e;
  --amber: #b7791f;
  --red: #b42318;
  --green: #237a57;
  font-family: Figtree, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: #f4f7fb;
  overflow-x: hidden;
}
a { color: var(--teal-dark); text-decoration: none; font-weight: 700; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.45rem, 2.2vw, 2rem); line-height: 1.15; margin-bottom: 0; letter-spacing: 0; }
h2 { font-size: 1rem; line-height: 1.35; }
table { border-collapse: collapse; width: 100%; min-width: 680px; }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0; }

.app-frame {
  min-height: 100vh;
}
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem 1.25rem;
}
.top-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: #172033;
  font-size: 1.1rem;
  font-weight: 800;
}
.side-nav {
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 256px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  box-shadow: 1px 0 2px rgba(15, 23, 42, 0.03);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #d7e2ec;
  color: #1f2937;
  font-weight: 900;
}
.side-links {
  display: grid;
  gap: 0.5rem;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}
.side-links a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 38px;
  border-left: 4px solid transparent;
  border-radius: 8px;
  padding: 0.38rem 0.55rem;
  color: #111827;
  font-size: 1.02rem;
  font-weight: 650;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.side-links a:hover {
  background: #f3f4f6;
}
.side-links a.active {
  background: #e6edff;
  border-left-color: #2563eb;
  color: #2563eb;
}
svg {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side-links svg {
  color: #64748b;
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
}
.side-links a.active svg {
  color: #2563eb;
}
.side-footer {
  display: grid;
  gap: 0.3rem;
  margin-top: auto;
  padding: 1rem 1.1rem 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}
.app-main {
  min-width: 0;
  margin-left: 256px;
  padding-top: 64px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 52px;
  background: #f3f4f6;
  border-bottom: 1px solid #eef0f3;
  color: #64748b;
  padding: 0 1.5rem;
}
.breadcrumb span {
  display: inline-grid;
  place-items: center;
}
.breadcrumb b {
  color: #334155;
  font-size: 1rem;
  font-weight: 650;
}
.top-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.top-user span {
  color: #4b5563;
  font-size: 0.95rem;
  font-weight: 700;
}
.top-user small {
  color: var(--muted);
  font-weight: 700;
}
.export-link,
.top-user button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 38px;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-weight: 800;
  color: #4b5563;
}
.export-link {
  border-color: #cfd8e3;
  color: #2563eb;
}
.top-user button {
  color: var(--navy);
}
.icon-button {
  width: 38px;
  padding: 0;
}
.app-shell { min-height: calc(100vh - 76px); }
.content-shell { min-width: 0; }
.view-stack {
  display: grid;
  gap: 1.25rem;
  max-width: 100%;
  margin: 0 auto;
  padding: 1.45rem 1.5rem 4rem;
}
.view-stack.narrow { max-width: 980px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  margin: -1.45rem -1.5rem 0;
  padding: 1rem 1.5rem;
}
.sticky-top { position: sticky; top: 0; z-index: 5; padding: 0.85rem 0; backdrop-filter: blur(12px); }
.header-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: flex-end; }
.eyebrow { color: #64748b; font-weight: 900; text-transform: uppercase; font-size: 0.74rem; margin-bottom: 0.25rem; letter-spacing: 0.16em; }
.loading { display: grid; place-items: center; min-height: 100vh; font-weight: 800; }
.error { color: var(--red); font-weight: 700; margin: 0; }

.primary-btn, .secondary-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.68rem 1rem;
  font-weight: 800;
  min-height: 42px;
}
.primary-btn { background: #172033; color: white; }
.primary-btn:hover { background: #0f172a; }
.secondary-btn { background: #fff; color: var(--navy); border-color: var(--line); }

@media (max-width: 920px) {
  .top-nav {
    min-height: 58px;
    padding: 0.45rem 0.85rem;
  }
  .top-brand {
    font-size: 1rem;
  }
  .side-nav {
    position: static;
    height: auto;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    margin-top: 58px;
  }
  .side-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
  }
  .side-links a {
    justify-content: center;
    border-left: 0;
    border-bottom: 3px solid transparent;
    min-height: 48px;
    padding: 0.55rem;
    text-align: center;
  }
  .side-links a.active {
    border-left-color: transparent;
    border-bottom-color: #2563eb;
  }
  .side-footer {
    display: none;
  }
  .app-main {
    margin-left: 0;
    padding-top: 0;
  }
  .breadcrumb {
    display: none;
  }
  .top-user {
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
  }
  .top-user small {
    display: none;
  }
  .page-header { align-items: flex-start; flex-direction: column; }
  table { min-width: 560px; }
}

@media (max-width: 560px) {
  h1 { font-size: 1.42rem; }
  .brand-mark { width: 34px; height: 34px; }
  .top-brand span:not(.brand-mark) { display: none; }
  .side-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.65rem;
  }
  .side-links a {
    gap: 0.45rem;
    font-size: 0.88rem;
    min-height: 44px;
    padding: 0.5rem 0.45rem;
  }
  .side-links svg {
    width: 1rem;
    height: 1rem;
  }
  .top-user span {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .export-link span,
  .top-user button span {
    display: none;
  }
  .view-stack {
    gap: 0.9rem;
    padding: 1rem 0.75rem 2.5rem;
  }
  .page-header {
    margin: -1rem -0.75rem 0;
    padding: 0.9rem 0.75rem;
  }
  .header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
  .primary-btn, .secondary-btn {
    justify-content: center;
    text-align: center;
    width: 100%;
  }
  table { min-width: 520px; }
  th, td { padding: 0.62rem; }
}
