:root {
  color-scheme: dark;
  --canvas: #081523;
  --deep: #050e19;
  --surface: #0e2032;
  --surface-raised: #142a40;
  --line: #284257;
  --text: #edf5fb;
  --muted: #a4bbcd;
  --faint: #7e9ab2;
  --accent: #77b5ff;
  --on-accent: #071a2c;
  --gold: #f0c775;
  --mint: #78d5bf;
  --danger: #ffaaa5;
  --radius: 16px;
  --small-radius: 9px;
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
}
:root[data-accent="gold"] { --accent: #f0c775; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px;
}
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.45rem); letter-spacing: -.042em; line-height: 1.14; }
h2 { font-size: 1.27rem; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
p, small { color: var(--muted); }
svg { flex: 0 0 auto; vertical-align: middle; }
.brand { display: inline-flex; gap: .75rem; align-items: center; flex: 0 0 auto; color: var(--text); text-decoration: none; font-size: 1.12rem; white-space: nowrap; letter-spacing: -.018em; }
.brand img { border-radius: 11px; }
.brand strong { color: var(--accent); font-weight: 650; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 42px; padding: .58rem .85rem; border: 1px solid var(--line); border-radius: var(--small-radius);
  background: var(--surface-raised); color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.button:not(:disabled):hover { background: #203b55; border-color: #42637e; }
.button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.button.primary:not(:disabled):hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.1); }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.danger { color: var(--danger); }
.icon-button { padding: .58rem; width: 42px; }
input, select, textarea {
  min-height: 42px; min-width: 0; color: var(--text); border: 1px solid var(--line); border-radius: var(--small-radius);
  background: var(--deep); padding: .58rem .7rem;
}
textarea { min-height: 100px; resize: vertical; }
input::placeholder { color: var(--faint); }
input[type="checkbox"] { min-height: 16px; width: 16px; accent-color: var(--accent); }
label { display: grid; gap: .4rem; font-size: .88rem; font-weight: 600; color: var(--muted); }
label.checkbox { display: flex; align-items: center; gap: .62rem; }
.form { display: grid; gap: 1rem; }
.form .button { justify-self: start; }
.form-row, .toolbar, .actions { display: flex; align-items: end; gap: .65rem; flex-wrap: wrap; }
.form-row > label { flex: 1 1 150px; }
.grow { flex: 1 1 220px; }
.spaced { justify-content: space-between; }
.flow { display: grid; gap: 1.05rem; min-width: 0; }
.notice { padding: .82rem 1rem; border-radius: var(--small-radius); background: #183046; border: 1px solid var(--line); color: var(--text); }
.notice.error { color: var(--danger); background: #302129; border-color: #623e49; }
.notice.success { color: var(--mint); }
.startup { display: grid; min-height: 100dvh; place-content: center; color: var(--muted); }
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(340px, .78fr); }
.auth-scene {
  display: flex; flex-direction: column; justify-content: space-between; gap: 4rem; padding: clamp(1.5rem, 4vw, 4rem);
  background: linear-gradient(180deg, #04101dcc, #08152319 32%, #081523e8 91%), url("/assets/hafen-desk-bg.jpg") center/cover no-repeat;
  min-height: 100%;
}
.auth-intro { max-width: 36rem; padding-bottom: 5vh; }
.auth-intro h1 { font-size: clamp(2.4rem, 5vw, 4.6rem); font-weight: 700; }
.auth-intro p { margin-top: .9rem; font-size: 1.05rem; }
.auth-form { display: grid; place-items: center; padding: clamp(1.25rem, 5vw, 4rem); background: #0b1827; }
.auth-card { width: min(100%, 390px); }
.auth-card h2 { font-size: 2rem; }
.auth-card p { margin: .55rem 0 1.55rem; }
.auth-card .button { width: 100%; }
#code { font-size: 1.5rem; letter-spacing: .24em; }
.desk { min-height: 100dvh; background: radial-gradient(ellipse at 75% 0, #12293e, transparent 56%), var(--canvas); }
.topbar {
  position: sticky; z-index: 3; top: 0; min-height: 66px; padding: .75rem clamp(1rem, 3vw, 3.5rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #071322f5; border-bottom: 1px solid var(--line);
}
.topbar-date { color: var(--muted); font-size: .92rem; }
.profile { display: flex; align-items: center; gap: .6rem; }
.identity { display: grid; min-width: 90px; max-width: 170px; line-height: 1.2; }
.identity strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .9rem; }
.identity small { font-size: .74rem; margin-top: .2rem; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #203d56; color: #c3e6fb; font-weight: 700; }
.workspace { width: min(100%, 1510px); margin: 0 auto; padding: clamp(1rem, 3vw, 2.8rem) clamp(1rem, 3vw, 3.8rem) 8rem; }
.workspace:focus { outline: none; }
.hero {
  position: relative; display: flex; min-height: 250px; align-items: end; overflow: hidden;
  padding: clamp(1.4rem, 3.7vw, 3.1rem); border: 1px solid #335170; border-radius: 24px;
  background: linear-gradient(85deg, #071421f7, #0b1c2a94 51%, #09172818), url("/assets/hafen-desk-bg.jpg") center 66%/cover;
}
.hero-content { max-width: 550px; }
.hero h1 { font-size: clamp(2.45rem, 4.5vw, 4.15rem); }
.hero p { margin-top: .55rem; color: #c1d9e8; }
.hero .button { margin-top: 1.05rem; }
.hero .date-label { color: var(--gold); font-size: .84rem; font-weight: 650; margin: 0 0 .45rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel { background: #0f2235e8; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.panel.pad { padding: clamp(1rem, 2.1vw, 1.5rem); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .85rem; }
.panel-head h2 { min-width: 0; }
.panel-head .button { min-height: 36px; padding: .35rem .65rem; }
.module-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }
.module-header p { margin-top: .32rem; }
.list { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; }
.list-row { display: flex; gap: .7rem; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); min-height: 54px; padding: .7rem 0; min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-row strong { overflow-wrap: anywhere; }
.list-row small { display: block; overflow-wrap: anywhere; }
.status-pill { display: inline-flex; align-items: center; padding: .24rem .56rem; border-radius: 5px; background: #17364b; color: #c5e1f3; font-size: .76rem; white-space: nowrap; }
.status-pill.positive { color: var(--mint); background: #183c42; }
.status-pill.warn { color: var(--gold); background: #382f29; }
.status-pill.error { color: var(--danger); background: #392532; }
.table-wrap { overflow: auto; overflow-anchor: none; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .74rem .9rem; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { background: #122a40; color: #b6cadd; font-size: .79rem; white-space: nowrap; text-align: left; }
td { font-size: .89rem; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #163047; }
td .button { padding: .36rem .63rem; min-height: 34px; }
.table-note { padding: 1rem; color: var(--muted); }
.dock-wrap { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 1rem max(1rem, env(safe-area-inset-bottom)); pointer-events: none; }
.dock {
  display: flex; gap: .18rem; padding: .4rem .5rem; max-width: 100%; overflow: auto; pointer-events: auto;
  border: 1px solid #354f69; border-radius: 18px; background: #091928f2; backdrop-filter: blur(16px);
  box-shadow: 0 14px 36px #0005;
}
.dock-link {
  position: relative; display: grid; place-items: center; align-content: center; gap: .24rem;
  min-width: 67px; min-height: 56px; padding: .38rem .55rem; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-size: .72rem; white-space: nowrap;
}
.dock-link:hover { background: #16324b; color: var(--text); }
.dock-link[aria-current="page"] { color: var(--text); background: #214663; }
.dock-link[aria-current="page"] svg { color: var(--accent); }
.dialog {
  width: min(680px, calc(100vw - 2rem)); max-height: 88dvh; padding: 0; color: var(--text);
  border: 1px solid #34516b; border-radius: 19px; background: var(--surface);
}
.dialog::backdrop { background: #01060cb0; }
.dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: .65rem; border-bottom: 1px solid var(--line); padding: .9rem 1.2rem; background: var(--surface); z-index: 1; }
.dialog-content { padding: 1.16rem 1.2rem 1.5rem; }
.dialog-content .notice { margin-top: .45rem; }
.toast { z-index: 8; position: fixed; right: 1.1rem; bottom: 6rem; max-width: min(440px, calc(100vw - 2.2rem)); border-radius: 10px; padding: .8rem 1rem; border: 1px solid var(--line); background: #163849; color: var(--text); }
.toast.error { background: #392532; border-color: #704b55; }
.text-link { border: 0; background: none; color: var(--accent); padding: 0; text-align: left; font-weight: 650; overflow-wrap: anywhere; }
.text-link:hover { text-decoration: underline; }
.details { border-top: 1px solid var(--line); margin: 0; display: grid; grid-template-columns: minmax(125px, .6fr) 1fr; }
.details dt, .details dd { margin: 0; padding: .6rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.details dt { color: var(--muted); padding-right: .5rem; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.shortcuts .panel { display: grid; gap: .6rem; justify-items: start; }
.loader { color: var(--muted); padding: 1.2rem; }
@media (max-width: 800px) {
  .topbar-date { display: none; }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-scene { min-height: 290px; gap: 2rem; }
  .auth-intro { padding-bottom: .25rem; }
  .auth-intro h1 { font-size: clamp(2.3rem, 9vw, 3.5rem); }
  .auth-form { padding-top: 2rem; }
}
@media (max-width: 560px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .hero { min-height: 215px; }
  .profile { gap: .2rem; }
  .identity, .avatar, #fullscreen { display: none; }
  .topbar .button { padding: .47rem .5rem; min-height: 36px; }
  .dock-wrap { padding-inline: .5rem; }
  .dock-link { min-width: 60px; }
  th, td { padding: .65rem .7rem; }
  .form-row { align-items: stretch; }
}
