:root {
  color-scheme: light dark;
  --accent: #1d4e63;
  --accent-strong: #163d4e;
  --accent-soft: #e3edf1;
  --bg: #eceff2;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #16212b;
  --muted: #5a6b78;
  --border: #d7dfe5;
  --border-strong: #c2ccd4;
  --danger: #b23a3a;
  --danger-soft: #f7e6e6;
  --shadow: 0 1px 2px rgba(22, 33, 43, .06), 0 6px 20px rgba(22, 33, 43, .05);
  --radius: 10px;
  --radius-sm: 7px;
  --st-new-bg: #e3edf1; --st-new-fg: #1d4e63;
  --st-prog-bg: #fbecd4; --st-prog-fg: #8a5a12;
  --st-wait-bg: #e7ebef; --st-wait-fg: #4f5e6a;
  --st-done-bg: #dcefe2; --st-done-fg: #1f6b41;
  --st-cancel-bg: #f4e0de; --st-cancel-fg: #97362e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7fb3c9;
    --accent-strong: #a6cad9;
    --accent-soft: #23323b;
    --bg: #12181d;
    --surface: #1a222a;
    --surface-2: #212b34;
    --ink: #e6edf1;
    --muted: #9aabb6;
    --border: #2c3842;
    --border-strong: #3a4954;
    --danger: #e08a8a;
    --danger-soft: #3a2626;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
    --st-new-bg: #23323b; --st-new-fg: #9cc7d7;
    --st-prog-bg: #3d3016; --st-prog-fg: #e5bd78;
    --st-wait-bg: #29333b; --st-wait-fg: #adbcc7;
    --st-done-bg: #1e3a2a; --st-done-fg: #8fd3a8;
    --st-cancel-bg: #3d2523; --st-cancel-fg: #e6a29b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15.5px/1.55 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 4vw;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand {
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
}
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}
nav a:hover { background: var(--surface-2); color: var(--ink); }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .92rem; }
.account form { margin: 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 30px 20px 72px; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; margin: 0 0 18px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }

.panel, .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.auth-card, .narrow { max-width: 520px; margin: 48px auto; }
.page-heading, .inline-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.page-heading { justify-content: space-between; align-items: center; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  transition: background .15s ease, transform .05s ease;
}
button:hover, .button:hover { background: var(--accent-strong); }
button:active, .button:active { transform: translateY(1px); }
button.secondary { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--danger); }
button.danger:hover { filter: brightness(.94); }
.link-button {
  padding: 0; background: transparent; color: var(--accent);
  border: 0; text-decoration: underline; font-weight: 500;
}
.link-button:hover { background: transparent; color: var(--accent-strong); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 22px 0; }
.metrics article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  gap: 3px;
  box-shadow: var(--shadow);
}
.metrics strong { font-size: 2.1rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.metrics span { color: var(--muted); font-size: .88rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 600; text-decoration: none; }

.status {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--surface-2);
  color: var(--muted);
}
.status--NEW { background: var(--st-new-bg); color: var(--st-new-fg); }
.status--IN_PROGRESS { background: var(--st-prog-bg); color: var(--st-prog-fg); }
.status--WAITING_CLIENT { background: var(--st-wait-bg); color: var(--st-wait-fg); }
.status--COMPLETED { background: var(--st-done-bg); color: var(--st-done-fg); }
.status--CANCELLED { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.detail-grid .panel { margin: 0; }
dl { display: grid; grid-template-columns: minmax(110px, 0.5fr) 1fr; gap: 8px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

.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: var(--radius-sm); background: var(--surface-2); }
.photos figcaption { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 500; margin: 10px 0; }
.checkbox input { width: 18px; height: 18px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.metric-text { font-size: 1.15rem !important; overflow-wrap: anywhere; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-size: .9em; }

.notice { padding: 11px 15px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); margin: 0 0 18px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--st-done-bg); color: var(--st-done-fg); }
.muted, time { color: var(--muted); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment { border-top: 1px solid var(--border); padding: 13px 0; }
.comment time { margin-left: 8px; font-size: .85rem; }
.history { padding-left: 20px; display: grid; gap: 6px; }
.history li { color: var(--ink); }
.filters { display: grid; gap: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .account { width: 100%; justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  h1 { font-size: 1.45rem; }
}
