:root {
  color-scheme: light;
  --ink: #172033;
  --ink-soft: #5f6878;
  --navy: #14284a;
  --navy-deep: #0c1b35;
  --blue: #245ba8;
  --blue-soft: #e8f0fb;
  --bordeaux: #7d2948;
  --bordeaux-soft: #f6e9ee;
  --green: #21705d;
  --green-soft: #e4f4ef;
  --amber: #a96716;
  --amber-soft: #fff2db;
  --danger: #a53636;
  --danger-soft: #fdecec;
  --line: #dfe4ec;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --shadow: 0 18px 46px rgba(20, 40, 74, 0.10);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--bordeaux);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.muted { color: var(--ink-soft); }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.08fr) minmax(420px, 0.92fr); }
.login-brand {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(36px, 6vw, 80px);
  color: white;
  background:
    radial-gradient(circle at 85% 18%, rgba(125, 41, 72, 0.82), transparent 32%),
    linear-gradient(145deg, var(--navy-deep), var(--navy) 58%, #253f6b);
}
.login-brand::after {
  position: absolute;
  right: -120px;
  bottom: -150px;
  width: 430px;
  height: 430px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02);
  content: "";
}
.login-statement { position: relative; z-index: 1; max-width: 720px; }
.login-statement .eyebrow { color: #e6b6c8; }
.login-statement h1 { max-width: 680px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.5rem, 5vw, 5rem); font-weight: 500; line-height: .98; letter-spacing: -.045em; }
.login-statement p:last-child { max-width: 610px; margin: 28px 0 0; color: rgba(255,255,255,.76); font-size: 1.05rem; line-height: 1.7; }
.login-version { z-index: 1; margin: 0; color: rgba(255,255,255,.56); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.login-panel { display: grid; min-height: 100vh; place-items: center; padding: 32px; background: #f8f9fb; }
.login-card { display: grid; width: min(440px, 100%); gap: 22px; padding: clamp(28px, 4vw, 48px); border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2.2rem; font-weight: 500; }
.login-card p { margin: 8px 0 0; line-height: 1.55; }

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup > span:last-child { display: grid; }
.brand-lockup strong { font-size: .94rem; letter-spacing: .08em; }
.brand-lockup small { margin-top: 2px; opacity: .64; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.brand-mark { display: grid; width: 39px; height: 39px; place-items: center; border: 1px solid currentColor; border-radius: 10px; font-family: Georgia, serif; font-size: 1.35rem; }
.brand-lockup--large .brand-mark { width: 50px; height: 50px; }

label { display: grid; gap: 7px; color: #364053; font-size: .84rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #ccd3de;
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  transition: border-color .16s, box-shadow .16s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,91,168,.12); }
.form-error { padding: 10px 12px; border-radius: 8px; color: var(--danger); background: var(--danger-soft); font-size: .84rem; }
.security-note { color: var(--ink-soft); font-size: .74rem; text-align: center; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-size: .82rem; font-weight: 800; transition: transform .14s, background .14s, border-color .14s; }
.button:hover { transform: translateY(-1px); }
.button--primary { color: white; background: var(--navy); }
.button--primary:hover { background: #1d3762; }
.button--secondary { color: var(--navy); border-color: #c9d4e5; background: white; }
.button--danger { color: var(--danger); border-color: #e8baba; background: white; }
.button--wide { width: 100%; }
.button--small { min-height: 32px; padding: 6px 10px; font-size: .74rem; }
.text-button { border: 0; padding: 0; color: #bbc7da; background: none; font-size: .75rem; text-align: left; }
.text-button:hover { color: white; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; font-size: 1.15rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; color: white; background: var(--navy-deep); }
.sidebar-head { display: grid; gap: 18px; padding: 28px 24px 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.core-badge { justify-self: start; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 4px 8px; color: #b9c8de; font-size: .62rem; font-weight: 800; letter-spacing: .08em; }
.main-nav { display: grid; gap: 3px; padding: 18px 14px; overflow-y: auto; }
.nav-item { display: grid; grid-template-columns: 30px 1fr; align-items: center; border: 0; border-radius: 9px; padding: 11px 12px; color: #bac5d7; background: transparent; font-size: .79rem; font-weight: 700; text-align: left; }
.nav-item span { color: #6f809c; font-size: .62rem; letter-spacing: .08em; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: white; background: linear-gradient(90deg, rgba(125,41,72,.62), rgba(125,41,72,.28)); }
.nav-item.is-active span { color: #efbfd0; }
.sidebar-foot { margin-top: auto; padding: 20px 24px 25px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-chip > span:last-child { display: grid; min-width: 0; }
.user-chip strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { margin-top: 2px; color: #8897af; font-size: .66rem; }
.avatar { display: grid; width: 35px; height: 35px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: white; background: var(--bordeaux); font-size: .7rem; font-weight: 800; }

.workspace { min-width: 0; }
.topbar { display: flex; min-height: 92px; align-items: center; justify-content: space-between; gap: 24px; padding: 20px clamp(22px, 4vw, 54px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.topbar h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 2.5vw, 2.1rem); font-weight: 500; letter-spacing: -.02em; }
.topbar-meta { display: flex; align-items: center; gap: 18px; color: var(--ink-soft); font-size: .73rem; }
.status-dot { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; background: white; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: #2a9a72; box-shadow: 0 0 0 4px rgba(42,154,114,.12); }
.page-content { max-width: 1600px; margin: 0 auto; padding: clamp(24px, 4vw, 52px); outline: none; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: 500; }
.page-head p { max-width: 720px; margin: 7px 0 0; color: var(--ink-soft); font-size: .86rem; line-height: 1.55; }
.head-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric-card { position: relative; overflow: hidden; min-height: 132px; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); box-shadow: 0 8px 24px rgba(20,40,74,.04); }
.metric-card::before { position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--blue); content: ""; }
.metric-card:nth-child(2)::before, .metric-card:nth-child(5)::before { background: var(--bordeaux); }
.metric-card:nth-child(3)::before, .metric-card:nth-child(6)::before { background: var(--green); }
.metric-label { color: var(--ink-soft); font-size: .71rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.metric-value { display: block; margin-top: 12px; font-family: Georgia, serif; font-size: 2.25rem; line-height: 1; }
.metric-note { display: block; margin-top: 10px; color: #7a8391; font-size: .7rem; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 8px 24px rgba(20,40,74,.035); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: .88rem; }
.panel-body { padding: 18px; }
.panel-spaced { margin-top: 18px; }

.data-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.search-box { position: relative; width: min(380px, 100%); }
.search-box input { padding-left: 34px; background: white; }
.search-box::before { position: absolute; top: 10px; left: 12px; color: #8791a1; content: "⌕"; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { padding: 11px 14px; color: #697386; background: #f7f8fa; font-size: .66rem; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 13px 14px; border-top: 1px solid #e9edf2; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
.cell-title { display: grid; gap: 3px; }
.cell-title strong { color: var(--ink); font-size: .8rem; }
.cell-title small { color: #7e8796; font-size: .69rem; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: .65rem; font-weight: 800; white-space: nowrap; }
.badge--green { color: var(--green); background: var(--green-soft); }
.badge--blue { color: var(--blue); background: var(--blue-soft); }
.badge--bordeaux { color: var(--bordeaux); background: var(--bordeaux-soft); }
.badge--amber { color: var(--amber); background: var(--amber-soft); }
.badge--gray { color: #636d7c; background: #edf0f4; }
.badge--red { color: var(--danger); background: var(--danger-soft); }

.empty-state { display: grid; min-height: 230px; place-items: center; padding: 34px; color: var(--ink-soft); text-align: center; }
.empty-state > div { max-width: 440px; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.empty-state p { margin: 0; font-size: .82rem; line-height: 1.55; }
.loading-state { display: flex; min-height: 280px; align-items: center; justify-content: center; gap: 10px; color: var(--ink-soft); font-size: .82rem; }
.spinner { width: 17px; height: 17px; border: 2px solid #d5dbe5; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 13px 1fr; gap: 10px; padding-bottom: 15px; }
.timeline-item::before { position: absolute; top: 12px; bottom: -2px; left: 4px; width: 1px; background: var(--line); content: ""; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { z-index: 1; width: 9px; height: 9px; margin-top: 3px; border: 2px solid white; border-radius: 50%; background: var(--bordeaux); box-shadow: 0 0 0 1px var(--bordeaux); }
.timeline-copy { display: grid; gap: 3px; }
.timeline-copy strong { font-size: .75rem; }
.timeline-copy small { color: var(--ink-soft); font-size: .65rem; }

.tabs { display: flex; gap: 5px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-bottom: 2px solid transparent; padding: 10px 13px; color: var(--ink-soft); background: transparent; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.tab.is-active { color: var(--bordeaux); border-bottom-color: var(--bordeaux); }

.dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 36px); border: 0; border-radius: 16px; padding: 0; color: var(--ink); box-shadow: 0 30px 90px rgba(6,16,35,.34); }
.dialog::backdrop { background: rgba(8,20,40,.62); backdrop-filter: blur(2px); }
.dialog-shell { margin: 0; }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 22px; border-bottom: 1px solid var(--line); background: white; }
.dialog-head h2 { margin: 0; font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.dialog-content { max-height: calc(100vh - 130px); overflow-y: auto; padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; grid-column: 1 / -1; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.detail-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fafbfc; }
.detail-card small { display: block; color: var(--ink-soft); font-size: .64rem; letter-spacing: .05em; text-transform: uppercase; }
.detail-card strong { display: block; margin-top: 7px; font-family: Georgia, serif; font-size: 1.35rem; font-weight: 500; }
.section-title { margin: 24px 0 10px; font-size: .83rem; }

.toast-region { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; width: min(370px, calc(100vw - 40px)); gap: 8px; }
.toast { border-left: 4px solid var(--green); border-radius: 10px; padding: 13px 15px; color: white; background: #1d2d42; box-shadow: var(--shadow); font-size: .78rem; animation: toast-in .2s ease-out; }
.toast.is-error { border-left-color: #f17676; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-only { display: none; }
@media (max-width: 1020px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { min-height: 42vh; }
  .login-panel { min-height: 58vh; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; width: 260px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(8,20,40,.24); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { justify-content: flex-start; }
  .topbar-meta { margin-left: auto; }
}
@media (max-width: 760px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .topbar { min-height: 78px; padding: 14px 18px; }
  .topbar-meta > span:first-child { display: none; }
  .page-content { padding: 22px 16px 38px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .login-brand { padding: 30px 24px; }
  .login-statement h1 { font-size: 2.7rem; }
  .login-panel { padding: 20px; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .status-dot { display: none; }
}
