* { box-sizing: border-box; }

:root {
  --pemi-orange: #FF7100;
  --pemi-anthracite: #3F3F3F;
  --graphite: #262626;
  --on-anthracite: #fff;
  --on-orange: #191919;
  --canvas: #f1f2f3;
  --surface: #fff;
  --surface-raised: #eeeef0;
  --text: #242424;
  --muted: #55565a;
  --line: #d8d9dc;
  --sidebar-divider: #b0b0b0;
  --shadow: #00000014;
  --scrim: #171717b8;
  --radius: 12px;
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
  background: var(--canvas);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #202020;
  --surface: #2b2b2b;
  --surface-raised: #363636;
  --text: #f4f4f4;
  --muted: #c2c2c5;
  --line: #505053;
  --shadow: #00000042;
}

body, h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 2; top: .5rem; left: .5rem; padding: .75rem; background: var(--surface); transform: translateY(-150%); }
.skip:focus { transform: none; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding: 1.5rem 1rem;
  background: var(--pemi-anthracite);
  color: var(--on-anthracite);
}
.brand { display: grid; justify-items: center; gap: .25rem; margin: 0 .35rem; font-size: 1.1rem; font-weight: 700; }
.brand-logo { display: block; max-width: 100%; height: auto; }
.brand .brand-logo { width: 192px; }
nav { display: grid; gap: .3rem; }
nav a { display: flex; align-items: center; gap: .65rem; min-height: 44px; padding: .55rem .7rem; border-radius: 8px; white-space: nowrap; }
nav a span { width: 1.4em; text-align: center; font-size: 1.15rem; }
nav a:hover { background: var(--graphite); }
nav a[aria-current] { background: var(--pemi-orange); color: var(--on-orange); font-weight: 700; }
.sidebar-footer { margin-top: auto; padding: .8rem .35rem 0; border-top: 1px solid var(--sidebar-divider); font-size: .88rem; }

main { min-width: 0; }
.topbar, .entry-toolbar {
  min-height: 68px;
  padding: .65rem clamp(1rem, 2.8vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  background: var(--graphite);
  color: var(--on-anthracite);
}
.topbar-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: .5rem 1rem; }
.workspace { font-weight: 650; }
.session-link { text-decoration: underline; text-underline-offset: .2em; }
.theme-toggle { border: 1px solid currentColor; border-radius: 8px; padding: .45rem .7rem; background: transparent; color: inherit; cursor: pointer; }
.theme-toggle[aria-pressed="true"] { background: var(--pemi-orange); color: var(--on-orange); border-color: var(--pemi-orange); }

.content { padding: clamp(1rem, 2.8vw, 3rem); }
.intro { margin: .4rem 0 1.65rem; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.8rem); letter-spacing: -.035em; line-height: 1.12; }
h2 { font-size: 1.15rem; line-height: 1.3; }
.intro p { margin-top: .65rem; color: var(--muted); font-size: 1.06rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 16px var(--shadow); }
.metric { display: flex; flex-direction: column; gap: .55rem; padding: 1rem 1.2rem; border-top: 4px solid var(--pemi-orange); }
.metric:hover { background: var(--surface-raised); }
.metric span, .metric small { color: var(--muted); }
.metric strong { font-size: clamp(1.45rem, 2.65vw, 2.4rem); letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.panel { overflow: hidden; }
.panel-title, .toolbar { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.25rem; }
.panel-title { justify-content: space-between; background: var(--pemi-anthracite); color: var(--on-anthracite); }
.secondary, .primary { display: inline-block; padding: .55rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--text); font-weight: 650; cursor: pointer; }
.primary { border-color: var(--pemi-orange); background: var(--pemi-orange); color: var(--on-orange); }
.primary:hover { box-shadow: 0 0 0 2px var(--on-orange) inset; }
.primary:focus-visible { outline-color: var(--pemi-orange); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .95rem clamp(.75rem, 1.4vw, 1.5rem); border-bottom: 1px solid var(--line); }
th { background: var(--graphite); color: var(--on-anthracite); font-size: .92rem; font-weight: 650; }
tbody tr:hover { background: var(--surface-raised); }
tbody tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { text-align: right; }
td:last-child { font-variant-numeric: tabular-nums; }
.row-link { padding: .3rem 0; border: 0; background: transparent; color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--pemi-orange); text-underline-offset: .25em; cursor: pointer; text-align: left; }
.status { display: inline-block; padding: .25rem .65rem; border-radius: 7px; background: var(--surface-raised); font-size: .86rem; }
.status.pending { border-left: 3px solid var(--pemi-orange); font-weight: 650; }
.toolbar { align-items: end; background: var(--pemi-anthracite); color: var(--on-anthracite); }
.toolbar label { display: grid; gap: .3rem; font-size: .95rem; }
.toolbar label:first-child { flex: 1; max-width: 490px; }
input, select { width: 100%; min-height: 44px; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
input:focus-visible, select:focus-visible { outline-color: var(--pemi-orange); }
.result-count, .empty { padding: .8rem 1.25rem; color: var(--muted); font-size: .93rem; }

dialog { width: min(92vw, 480px); padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
dialog::backdrop { background: var(--scrim); }
dialog form { display: flex; justify-content: end; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

.sign-in { min-height: 100vh; background: var(--pemi-anthracite); }
.entry-toolbar { justify-content: end; }
.entry-card { display: grid; grid-template-columns: .95fr 1.05fr; gap: clamp(1.25rem, 3.5vw, 3rem); align-items: center; width: min(920px, calc(100% - 2rem)); margin: clamp(1rem, 8vh, 6rem) auto; padding: clamp(1rem, 3vw, 2.75rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 36px var(--shadow); }
.entry-image { background: var(--pemi-anthracite); }
.entry-image .brand-logo { width: 100%; }
.entry-content { display: grid; justify-items: start; gap: 1rem; }
.entry-content p { color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  nav a, .metric, .primary, .theme-toggle, tbody tr { transition: background-color 150ms ease, box-shadow 150ms ease; }
  dialog[open] { animation: appear 150ms ease-out; }
}
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 850px) {
  .layout { display: block; }
  .sidebar { padding: .8rem 1rem; gap: .6rem; }
  .brand { display: flex; align-items: center; gap: .75rem; }
  .brand .brand-logo { width: 104px; }
  nav { display: flex; overflow-x: auto; padding: .25rem; }
  .sidebar-footer { border: 0; padding: 0 .35rem; }
  .topbar { min-height: 56px; }
}
@media (max-width: 600px) {
  .metrics, .entry-card { grid-template-columns: 1fr; }
  .metrics { gap: .65rem; }
  .metric { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .2rem .6rem; padding: .75rem; border-top: 1px solid var(--line); border-left: 4px solid var(--pemi-orange); }
  .metric small { grid-column: 1 / -1; }
  .toolbar { display: grid; }
  .entry-image { width: min(100%, 300px); justify-self: center; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { display: block; border-bottom: 1px solid var(--line); padding: .55rem .9rem; }
  tr:last-child { border: 0; }
  td, td:last-child { display: flex; gap: .6rem; justify-content: space-between; align-items: center; border: 0; padding: .35rem 0; text-align: right; }
  td::before { content: attr(data-label); color: var(--muted); text-align: left; font-size: .88rem; }
  .row-link { min-height: 40px; }
}
