:root {
  color-scheme: light;
  --background: #f5f6fa;
  --surface: #fff;
  --ink: #181a2f;
  --muted: #555d73;
  --border: #e4e6f0;
  --accent: #5543bb;
  --accent-hover: #423294;
  --accent-soft: #eeebfc;
  --green: #116738;
  --green-soft: #e2f5e9;
  --red: #9c292f;
  --red-soft: #ffeced;
  --amber: #805100;
  --amber-soft: #fff0cf;
  --radius: 16px;
  font: 16px/1.5 "Segoe UI", "Inter", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #141622;
  --surface: #1d2031;
  --ink: #f2f1ff;
  --muted: #bbc0d6;
  --border: #33374d;
  --accent: #b6a8ff;
  --accent-hover: #c9c0ff;
  --accent-soft: #342d57;
  --green: #a4e7b6;
  --green-soft: #233d32;
  --red: #ffb4bc;
  --red-soft: #482c3a;
  --amber: #ffd994;
  --amber-soft: #473b29;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); line-height: 1.12; letter-spacing: -.043em; }
h2 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -.018em; }
h3 { font-size: 1rem; }
a { color: var(--accent); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; }
button, .button { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 8px 13px; font-size: .9rem; font-weight: 600; min-height: 41px; cursor: pointer; display: inline-flex; gap: .55rem; align-items: center; justify-content: center; text-decoration: none; }
button:hover, .button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .55; cursor: wait; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--red); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; min-width: 0; }
input, select, textarea { min-width: 0; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--ink); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
small, .muted, .meta { color: var(--muted); }
small, .meta { font-size: .86rem; }
[hidden] { display: none !important; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-width: 0; gap: 24px; padding: 27px 19px 19px; background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 7px; color: var(--ink); font-size: 1.13rem; font-weight: 800; letter-spacing: -.03em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--surface); font-size: 1.4rem; line-height: 1; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 0; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-size: .93rem; text-decoration: none; font-weight: 600; }
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-icon { display: inline-grid; place-items: center; width: 22px; color: inherit; font-size: 1.05rem; }
.nav-label { color: var(--muted); padding: 0 10px; margin: 12px 0 1px; font-size: .78rem; font-weight: 700; }
.side-footer { margin-top: auto; display: grid; gap: 8px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 69px; padding: 12px clamp(18px, 3vw, 39px); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .quiet { background: transparent; padding: 6px 10px; min-height: 35px; }
.topbar .crumb { font-size: .91rem; font-weight: 600; color: var(--muted); }
.mobile-menu { display: none; }
.content { max-width: 1500px; margin-inline: auto; padding: 30px clamp(18px, 3vw, 39px) 55px; display: grid; gap: 23px; }
.page-head { display: flex; justify-content: space-between; gap: 15px; align-items: end; padding: 4px 0 0; }
.page-head p { margin-bottom: 6px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.flex { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; align-content: start; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 17px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 19px; min-width: 0; }
.summary { display: grid; gap: 12px; }
.summary b { font-size: 2rem; font-weight: 730; letter-spacing: -.04em; line-height: 1.1; }
.summary .nav-icon { width: 37px; height: 37px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); min-width: 0; }
.row > .grow { flex: 1; min-width: 0; }
.row p { overflow-wrap: anywhere; }
.row-title { color: var(--ink); font-weight: 650; text-decoration: none; }
.row-title:hover { color: var(--accent); text-decoration: underline; }
.badge { font-size: .8rem; font-weight: 650; border-radius: 7px; padding: 3px 8px; background: var(--accent-soft); color: var(--accent); white-space: normal; }
.badge.success { color: var(--green); background: var(--green-soft); }
.badge.error { color: var(--red); background: var(--red-soft); }
.badge.warn { color: var(--amber); background: var(--amber-soft); }
.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 32px 12px; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }
.empty strong { color: var(--ink); }
.callout { padding: 12px 15px; border-radius: 9px; background: var(--accent-soft); color: var(--ink); overflow-wrap: anywhere; }
.callout.warn { background: var(--amber-soft); }
.inline-control { width: auto; }
.check { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.compact { gap: 8px; }
.link-button { border: 0; color: var(--accent); padding-inline: 0; background: transparent; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.thumb { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.thumb img { display: block; width: 100%; height: 90px; object-fit: cover; background: var(--accent-soft); }
.thumb button { border: 0; min-height: 33px; width: 100%; border-radius: 0; }
.drop { border: 1px dashed var(--border); padding: 14px; border-radius: 10px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.preview-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar.day { grid-template-columns: 1fr; }
.cell { min-height: 104px; padding: 8px; border: solid var(--border); border-width: 1px 0 0 1px; min-width: 0; }
.cell:nth-child(7n) { border-right-width: 1px; }
.cell.today { background: var(--accent-soft); }
.cell-head { min-height: 0; text-align: center; color: var(--muted); font-size: .82rem; padding: 7px 4px; }
.day-number { font-weight: 650; border: 0; background: transparent; min-height: 29px; padding: 2px 6px; }
.calendar-entry { display: block; padding: 3px 5px; margin-block: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 5px; font-size: .8rem; font-weight: 600; text-decoration: none; background: var(--accent-soft); color: var(--accent); }
.calendar-entry.ad { background: var(--amber-soft); color: var(--amber); }
.calendar-entry.error { background: var(--red-soft); color: var(--red); }
.calendar-entry.draft { background: var(--background); color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 9px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 650; }
dialog { padding: 22px; max-width: min(94vw, 670px); width: 100%; max-height: 90dvh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #1012229a; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login > .card { width: min(100%, 405px); padding: 28px; gap: 24px; }
#notice { position: fixed; bottom: 20px; inset-inline-end: 20px; max-width: min(470px, calc(100vw - 40px)); z-index: 20; }
#notice:empty { display: none; }
#notice div { padding: 11px 15px; color: var(--ink); background: var(--green-soft); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px #15192d25; }
#notice div.error { background: var(--red-soft); }

@media (max-width: 950px) {
  .shell { grid-template-columns: 188px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(80vw, 255px); box-shadow: 0 0 0 100vmax #16182570; }
  .sidebar:not(.open) { display: none; }
  .mobile-menu { display: inline-flex; }
  .content { padding-top: 19px; gap: 16px; }
  .topbar { min-height: 57px; }
  .page-head { align-items: start; flex-wrap: wrap; }
  .card { padding: 14px; }
  .summary { gap: 8px; }
  .cell { min-height: 65px; padding: 2px; }
  .calendar-entry { font-size: .7rem; }
}
