:root {
  color-scheme: light;
  --sidebar: #111b2b;
  --sidebar-raised: #1a273a;
  --sidebar-ink: #f7fafc;
  --sidebar-muted: #8fa0b8;
  --accent: #176b87;
  --accent-strong: #0f536b;
  --accent-soft: #e9f5f8;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #172333;
  --muted: #67758a;
  --border: #e1e7ed;
  --border-strong: #cbd5df;
  --danger: #b84343;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(19, 35, 54, .04);
  --shadow: 0 10px 30px rgba(19, 35, 54, .07);
  --radius: 16px;
  --radius-sm: 10px;
  --st-new-bg: #e4f3f8; --st-new-fg: #176b87; --st-new-dot: #2795b8;
  --st-prog-bg: #fff2d8; --st-prog-fg: #8a5b08; --st-prog-dot: #d99a21;
  --st-wait-bg: #eeeafd; --st-wait-fg: #6552a5; --st-wait-dot: #806cc5;
  --st-done-bg: #e5f5ea; --st-done-fg: #267047; --st-done-dot: #42a66b;
  --st-cancel-bg: #fbe9e7; --st-cancel-fg: #a3433c; --st-cancel-dot: #d36a62;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { display: grid; grid-template-columns: 254px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  overflow-y: auto;
  background: linear-gradient(180deg, #111b2b 0%, #0e1725 100%);
  color: var(--sidebar-ink);
}
.sidebar-brand, .mobile-brand, .auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.sidebar-brand { padding: 0 8px 24px; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #2889a8, #155b75);
  box-shadow: 0 8px 20px rgba(23, 107, 135, .28);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .03em;
}
.brand-copy, .account-copy, .auth-brand > span:last-child { min-width: 0; display: grid; line-height: 1.25; }
.brand-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.brand-copy small, .account-copy small, .auth-brand small { color: var(--sidebar-muted); font-size: .73rem; margin-top: 3px; }

.sidebar-nav { display: grid; gap: 5px; }
.nav-caption {
  margin: 20px 12px 7px;
  color: #687b95;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.nav-caption:first-child { margin-top: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 8px 11px;
  border-radius: 11px;
  color: #aebacd;
  text-decoration: none;
  font-weight: 600;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); transform: translateX(2px); }
.sidebar-nav a.active { color: #fff; background: var(--sidebar-raised); box-shadow: inset 3px 0 0 #42a0bd; }
.nav-symbol {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .055);
  color: #8eabc0;
  font-size: .9rem;
  font-weight: 800;
}
.sidebar-nav a.active .nav-symbol { color: #8fd4e8; background: rgba(73, 163, 192, .13); }
.sidebar-account {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 16px 7px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #dff7ff;
  background: #253a51;
  font-weight: 800;
}
.account-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.sidebar-account form { margin: 0; }
.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: var(--sidebar-muted);
  background: transparent;
}
.icon-button:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.workspace { min-width: 0; }
.page-content { width: min(1380px, 100%); margin: 0 auto; padding: 38px 42px 80px; }
.mobile-bar { display: none; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading h1, h1 { margin: 0; font-size: clamp(1.7rem, 2vw, 2.15rem); line-height: 1.2; letter-spacing: -.035em; }
.page-heading p { margin: 8px 0 0; }
.page-actions { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
h2 { margin: 0 0 17px; font-size: 1.08rem; letter-spacing: -.012em; }
h3 { margin: 22px 0 9px; font-size: .95rem; }
p:first-child { margin-top: 0; }

.panel, .auth-card, .table-wrap, .metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 24px; margin-bottom: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-header h2 { margin-bottom: 4px; }
.panel-header p { margin: 0; }
.subtle-panel { background: linear-gradient(135deg, #f9fbfc, #fff); }
.narrow { max-width: 590px; margin-inline: auto; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin: 0 0 24px; }
.metric-card { position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--metric-color, var(--accent)); }
.metric-card a { display: grid; gap: 2px; padding: 19px 20px 18px; color: inherit; text-decoration: none; }
.metric-card strong { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.metric-card span { margin-top: 7px; color: var(--ink); font-size: .85rem; font-weight: 700; }
.metric-card small { color: var(--muted); font-size: .73rem; }
.metric-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.metric-card--NEW { --metric-color: var(--st-new-dot); }
.metric-card--IN_PROGRESS { --metric-color: var(--st-prog-dot); }
.metric-card--WAITING_CLIENT { --metric-color: var(--st-wait-dot); }
.metric-card--COMPLETED { --metric-color: var(--st-done-dot); }
.metric-card--CANCELLED { --metric-color: var(--st-cancel-dot); }
.summary-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(270px, .6fr); gap: 20px; }
.quick-links { display: grid; gap: 10px; }
.quick-link { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 11px; color: var(--ink); text-decoration: none; font-weight: 700; }
.quick-link:hover { border-color: #a9c8d3; background: var(--accent-soft); }
.quick-link span:last-child { color: var(--accent); }

label { display: grid; gap: 7px; color: #455369; font-size: .82rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #93a0b1; }
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #aebbc7; }
:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 135, .13); }

button, .button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}
button:hover, .button:hover { background: var(--accent-strong); box-shadow: 0 5px 14px rgba(23, 107, 135, .16); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--ink); box-shadow: none; }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); }
button.danger, .button.danger { background: var(--danger); }
.link-button { min-height: 0; padding: 0; border: 0; background: transparent; color: var(--accent); box-shadow: none; text-decoration: underline; font-weight: 650; }
.link-button:hover { background: transparent; color: var(--accent-strong); box-shadow: none; }
.text-link { font-weight: 700; text-decoration: none; }
.back-link::before { content: "←"; margin-right: 6px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 17px; }
.form-grid .wide { grid-column: 1 / -1; }
.field-hint { color: var(--muted); font-size: .82rem; font-weight: 500; line-height: 1.4; }
.inline-form { display: flex; align-items: flex-end; gap: 11px; flex-wrap: wrap; }
.inline-form + .inline-form { margin-top: 14px; }
.inline-form label { min-width: 155px; }
.inline-form label.grow { flex: 1 1 280px; }
.filters { padding: 19px 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; gap: 12px; align-items: end; }
.search-row { display: flex; align-items: flex-end; gap: 10px; }
.search-row label { flex: 1; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.checkbox input { width: 18px; min-height: 18px; height: 18px; }
.compact-form { margin-top: 14px; padding: 16px; border-radius: 11px; background: var(--surface-2); }
.password-form, .comment-form { display: grid; gap: 16px; }
.comment-form { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.comment-form button { width: max-content; }
.settings-submit { position: sticky; bottom: 18px; z-index: 5; display: flex; justify-content: flex-end; margin: -3px 0 20px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); backdrop-filter: blur(10px); }

.table-wrap { overflow-x: auto; }
.panel .table-wrap { border-radius: 12px; box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: #718095; background: var(--surface-2); font-size: .7rem; font-weight: 800; letter-spacing: .085em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .13s ease; }
tbody tr:hover { background: #f9fbfc; }
td a { font-weight: 750; text-decoration: none; }
.cell-main { display: grid; gap: 2px; }
.cell-main small { color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty-state { padding: 44px 20px !important; color: var(--muted); text-align: center; }
.table-actions { display: grid; gap: 9px; min-width: 250px; }

.status {
  --status-dot: #8d99a8;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--status-dot); }
.status--NEW { --status-dot: var(--st-new-dot); background: var(--st-new-bg); color: var(--st-new-fg); }
.status--IN_PROGRESS { --status-dot: var(--st-prog-dot); background: var(--st-prog-bg); color: var(--st-prog-fg); }
.status--WAITING_CLIENT { --status-dot: var(--st-wait-dot); background: var(--st-wait-bg); color: var(--st-wait-fg); }
.status--COMPLETED { --status-dot: var(--st-done-dot); background: var(--st-done-bg); color: var(--st-done-fg); }
.status--CANCELLED { --status-dot: var(--st-cancel-dot); background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.state-pill { display: inline-flex; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 800; }
.state-pill.active { background: var(--st-done-bg); color: var(--st-done-fg); }
.role-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.role-card { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
.role-card > span { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 850; }
.role-card div { display: grid; gap: 3px; }
.role-card small { color: var(--muted); line-height: 1.35; }
.disclosure > summary { list-style: none; color: var(--ink); font-size: 1.08rem; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 9px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.disclosure[open] > summary::before { content: "−"; }
.disclosure-content { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.detail-grid .panel { margin: 0; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 20px; align-items: start; }
.detail-side { position: sticky; top: 22px; }
.info-list { display: grid; grid-template-columns: minmax(120px, .55fr) 1fr; gap: 10px 17px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 620; overflow-wrap: anywhere; }
.info-list.compact { gap-block: 7px; }
.fact-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.fact-line + .fact-line { margin-top: 9px; }
.section-note { padding: 13px 15px; border-left: 3px solid #91bbca; border-radius: 0 9px 9px 0; background: var(--accent-soft); color: #35596a; font-size: .88rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; padding: 6px 10px; border-radius: 9px; background: var(--surface-2); color: #455369; font-size: .8rem; font-weight: 700; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 170px; object-fit: cover; border-radius: 11px; background: var(--surface-2); }
.photos figcaption { margin-top: 5px; color: var(--muted); font-size: .78rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment { position: relative; margin-left: 12px; padding: 0 0 20px 22px; border-left: 2px solid var(--border); }
.comment::before { content: ""; position: absolute; top: 4px; left: -6px; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: #7aaabd; }
.comment:last-of-type { padding-bottom: 5px; }
.comment p { margin: 7px 0 0; }
.comment time { margin-left: 7px; color: var(--muted); font-size: .77rem; }
.history { margin: 0; padding: 0; list-style: none; }
.history li { position: relative; margin-left: 8px; padding: 0 0 20px 24px; border-left: 2px solid var(--border); }
.history li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); }
.history li:last-child { padding-bottom: 0; border-color: transparent; }
.history time { display: block; margin-bottom: 3px; font-size: .75rem; }

.notice { margin: 0 0 19px; padding: 12px 15px; border: 1px solid #cbe3eb; border-radius: 11px; background: var(--accent-soft); color: #28576a; }
.notice.error { border-color: #f0c7c7; background: var(--danger-soft); color: var(--danger); }
.notice.success { border-color: #c8e5d2; background: var(--st-done-bg); color: var(--st-done-fg); }
.muted, time { color: var(--muted); }
.danger-zone { border-color: #efcaca; background: #fffafa; }
.metric-text { font-size: 1.08rem !important; overflow-wrap: anywhere; }
code { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); font-size: .9em; }
details summary { cursor: pointer; color: var(--accent); font-weight: 700; }

.auth-body { min-height: 100vh; background: radial-gradient(circle at 15% 10%, #deeff4 0, transparent 35%), linear-gradient(135deg, #f6f8fa 0%, #edf2f5 100%); }
.auth-layout { min-height: 100vh; display: grid; place-content: center; padding: 28px 18px; }
.auth-brand { width: min(440px, 100%); margin: 0 auto 18px; color: var(--ink); }
.auth-brand small { color: var(--muted); }
.auth-card { width: min(440px, calc(100vw - 36px)); padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .muted { margin-bottom: 24px; }
.auth-card form { display: grid; gap: 16px; }
.auth-card button { margin-top: 3px; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, minmax(145px, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .role-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; min-height: 64px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .96); box-shadow: var(--shadow-sm); }
  .mobile-brand { min-width: 0; color: var(--ink); }
  .mobile-brand strong { max-width: min(58vw, 360px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; }
  .mobile-menu { position: relative; }
  .mobile-menu summary { width: 40px; height: 40px; display: grid; align-content: center; gap: 4px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; list-style: none; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu summary span { height: 2px; border-radius: 2px; background: var(--ink); }
  .mobile-menu nav { position: absolute; top: 48px; right: 0; width: min(280px, calc(100vw - 36px)); display: grid; gap: 3px; padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
  .mobile-menu nav a, .mobile-menu nav .link-button { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-align: left; text-decoration: none; }
  .mobile-menu nav a:hover { background: var(--surface-2); }
  .mobile-menu nav form { margin: 3px 0 0; padding-top: 7px; border-top: 1px solid var(--border); }
  .page-content { padding: 28px 22px 64px; }
  .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .page-content { padding-inline: 15px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 15px; }
  .page-actions, .page-actions form { width: 100%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card a { padding: 16px; }
  .metric-card strong { font-size: 1.7rem; }
  .detail-grid, .form-grid, .filter-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .filter-grid > button { width: 100%; }
  .search-row { align-items: stretch; flex-direction: column; }
  .search-row button { width: 100%; }
  .panel { padding: 19px 17px; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form label, .inline-form button, .inline-form .button { width: 100%; }
  .comment-form button { width: 100%; }
  .info-list { grid-template-columns: 1fr; gap: 3px; }
  .info-list dd { margin-bottom: 9px; }

  .responsive-table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .responsive-table table, .responsive-table tbody { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tr { display: grid; gap: 0; margin-bottom: 12px; padding: 9px 14px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
  .responsive-table td { display: grid; grid-template-columns: minmax(88px, .42fr) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
  .responsive-table td.empty-state { display: block; border: 0; }
  .table-actions { min-width: 0; }
  .settings-submit { bottom: 8px; }
}
@media (max-width: 410px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card span { font-size: .78rem; }
  .mobile-brand strong { max-width: 52vw; font-size: .85rem; }
  .role-grid { grid-template-columns: 1fr; }
}
