:root {
  --ink: #173f35;
  --ink-2: #315d52;
  --cream: #f5f1e8;
  --paper: #fffdf8;
  --line: #d9ded6;
  --mint: #c7e6d6;
  --mint-strong: #54a981;
  --orange: #e88b4a;
  --yellow: #f4cd62;
  --red: #c65353;
  --blue: #4d78a8;
  --shadow: 0 14px 40px rgba(23, 63, 53, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 92% 0, #d7eadf 0, transparent 28rem), var(--cream); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-loader { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--ink-2); }
.app-loader span { margin: auto; width: 34px; height: 34px; border: 3px solid var(--mint); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.brand { display: flex; gap: .75rem; align-items: center; font-weight: 800; letter-spacing: -.03em; font-size: 1.3rem; position: relative; z-index: 1; }
.brand-mark { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; background: var(--yellow); color: var(--ink); border-radius: .7rem; transform: rotate(-4deg); }
.auth-panel { width: min(28rem, 100%); }
.auth-card { background: var(--paper); border: 1px solid rgba(23,63,53,.1); border-radius: 1.2rem; padding: clamp(1.4rem, 5vw, 2.2rem); box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 2.5rem; }
.auth-card h2 { font-family: Georgia, serif; font-size: 2.3rem; font-weight: 500; margin: 0 0 .5rem; }
.muted { color: #688078; }

.field { display: grid; gap: .42rem; margin: 1rem 0; }
.field label { font-size: .82rem; font-weight: 760; letter-spacing: .02em; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: .8rem; background: #fff; color: var(--ink); padding: .78rem .9rem; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--mint-strong); box-shadow: 0 0 0 3px rgba(84,169,129,.16); }

.btn { border: 0; border-radius: .75rem; padding: .72rem 1rem; background: var(--ink); color: #fff; font-weight: 760; transition: transform .15s, opacity .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--mint); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.warn { background: var(--orange); }
.btn.small { padding: .48rem .7rem; font-size: .84rem; }
.actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 16.5rem 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.5rem 1.1rem; background: var(--ink); color: #fff; display: flex; flex-direction: column; z-index: 4; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 0 .6rem 1.6rem; }
.sidebar-close { display: none; }
.nav { display: grid; gap: .18rem; overflow-y: auto; }
.nav button { border: 0; border-radius: .7rem; padding: .7rem .8rem; background: transparent; color: #c8ddd5; text-align: left; display: flex; gap: .75rem; align-items: center; }
.nav button:hover, .nav button.active { background: rgba(255,255,255,.1); color: #fff; }
.nav .icon { width: 1.25rem; text-align: center; }
.nav .icon svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.sidebar-user { margin-top: auto; padding: 1rem .65rem .2rem; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: #aac7bd; margin-top: .18rem; }
.sidebar-logout { background: transparent; color: #fff; border: 1px solid #77978e; }
.sidebar-logout.with-user { margin-top: .8rem; }
.sidebar-logout:hover { background: rgba(255,255,255,.1); }
.sidebar-backdrop { display: none; }

.main { min-width: 0; }
.topbar { height: 4.8rem; display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: 0 clamp(1.2rem, 4vw, 3.5rem); border-bottom: 1px solid rgba(23,63,53,.09); background: rgba(245,241,232,.82); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 3; }
.mobile-menu { display: none; }
.search { width: min(30rem, 55vw); position: relative; }
.search input { padding-left: 2.6rem; background: rgba(255,255,255,.72); }
.search::before { content: "⌕"; position: absolute; left: .9rem; top: .48rem; font-size: 1.45rem; z-index: 1; color: #71857f; }
.bell { position: relative; flex: 0 0 2.7rem; display: grid; place-items: center; border: 0; padding: 0; background: var(--paper); color: var(--ink); border-radius: 50%; width: 2.7rem; height: 2.7rem; font-size: 1.15rem; box-shadow: 0 4px 15px rgba(23,63,53,.08); }
.bell svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.count { position: absolute; top: -.3rem; right: -.3rem; min-width: 1.25rem; height: 1.25rem; padding: 0 .25rem; border-radius: 1rem; background: var(--orange); color: #fff; font-size: .7rem; display: grid; place-items: center; font-weight: 800; }
.content { width: min(93rem, 100%); padding: clamp(1.25rem, 4vw, 3.5rem); margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.8rem; }
.page-head h1 { font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 500; letter-spacing: -.04em; margin: 0; }
.page-head p { margin: .4rem 0 0; color: #6d817b; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
.card { background: rgba(255,253,248,.93); border: 1px solid rgba(23,63,53,.1); border-radius: 1.15rem; padding: 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 1rem; margin: 0 0 1rem; display: flex; justify-content: space-between; align-items: center; }
.hero-points { background: var(--ink); color: #fff; padding: 1.6rem; position: relative; overflow: hidden; }
.hero-points::after { content: ""; width: 10rem; height: 10rem; position: absolute; right: -2rem; bottom: -5rem; border-radius: 50%; background: var(--mint-strong); opacity: .35; }
.points-number { font-family: Georgia, serif; font-size: 4.5rem; line-height: 1; }
.points-number small { font: 700 .9rem Inter, sans-serif; color: #bcd2c9; }
.kicker { color: #6d817b; text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 800; }
.hero-points .kicker { color: #bcd2c9; }

.list { display: grid; gap: .7rem; }
.item { border: 1px solid var(--line); border-radius: .9rem; padding: .9rem; background: rgba(255,255,255,.58); }
.item-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.item h3 { font-size: .97rem; margin: 0; }
.item p { color: #657972; font-size: .88rem; line-height: 1.5; margin: .45rem 0 .7rem; white-space: pre-wrap; }
.meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; color: #71857e; font-size: .78rem; }
.badge { display: inline-flex; align-items: center; border-radius: 2rem; padding: .25rem .55rem; background: var(--mint); color: var(--ink); font-weight: 760; font-size: .72rem; }
.badge.one-off { background: #f5dbbd; }
.badge.wait { background: #f4e9b5; }
.badge.alert { background: #f4cccc; color: #752c2c; }
.badge.blue { background: #d5e3f1; color: #315371; }
.score { flex: 0 0 auto; font-weight: 850; background: var(--yellow); color: var(--ink); padding: .35rem .58rem; border-radius: .6rem; }
.empty { padding: 2.2rem 1rem; text-align: center; color: #80918b; border: 1px dashed var(--line); border-radius: .9rem; }

.leader { display: grid; gap: .9rem; }
.leader-row { display: grid; grid-template-columns: minmax(6rem, 1fr) 4fr auto; gap: .7rem; align-items: center; font-size: .84rem; }
.bar { height: .55rem; background: #e4e7e0; border-radius: 1rem; overflow: hidden; }
.bar span { height: 100%; display: block; border-radius: inherit; background: var(--mint-strong); min-width: .35rem; }
.leader-row:first-child .bar span { background: var(--orange); }
.leader-row b { font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.tabs button { border: 1px solid var(--line); background: var(--paper); padding: .5rem .8rem; border-radius: 2rem; color: var(--ink-2); }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 10rem; margin: 0; }
.notice { border-left: 4px solid var(--orange); background: #fff5e8; padding: .8rem 1rem; border-radius: .5rem; font-size: .87rem; }
.comment { background: #f8edd7; border-radius: .7rem; padding: .65rem .75rem; margin-top: .6rem; font-size: .84rem; }
.comment strong { display: block; margin-bottom: .2rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; color: #71837e; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
th, td { border-bottom: 1px solid var(--line); padding: .72rem .5rem; }
.positive { color: #26805d; font-weight: 800; } .negative { color: var(--red); font-weight: 800; }
.toast { position: fixed; z-index: 20; right: 1.25rem; bottom: 1.25rem; max-width: 25rem; padding: .85rem 1rem; border-radius: .75rem; background: var(--ink); color: #fff; box-shadow: var(--shadow); transform: translateY(6rem); opacity: 0; transition: .25s; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--red); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(8rem,1fr)); gap: .5rem; margin: .7rem 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .65rem; }
.timeline { border-left: 2px solid var(--mint); padding-left: 1rem; display: grid; gap: .8rem; }
.timeline div { position: relative; font-size: .84rem; }
.timeline div::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--mint-strong); position: absolute; left: -1.35rem; top: .25rem; }
.settings-section { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.settings-section h3 { margin: 0; }
dialog.modal { border: 0; border-radius: 1rem; padding: 0; width: min(36rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); color: var(--ink); background: transparent; box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(23, 35, 31, .32); backdrop-filter: blur(2px); }
.modal-card { box-shadow: none; border: 0; }
.modal-card > h2 { margin-bottom: 1.25rem; }
.modal-card form > .btn:last-child { margin-top: .35rem; }
.modal-footer { display: flex; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

@media (max-width: 1000px) {
  .span-8, .span-7 { grid-column: span 12; }
  .span-4, .span-5, .span-6 { grid-column: span 6; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: fixed; width: min(17rem, calc(100vw - 3.5rem)); height: 100dvh; transform: translateX(-110%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .sidebar-header { padding-right: 0; }
  .sidebar-close { flex: 0 0 2.35rem; width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; padding: 0 0 .15rem; background: transparent; color: #fff; font-size: 1.65rem; line-height: 1; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 3; border: 0; padding: 0; background: rgba(17,36,31,.36); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.open + .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .mobile-menu { display: block; border: 0; background: transparent; font-size: 1.35rem; color: var(--ink); }
  .topbar { padding: 0 1rem; height: 4.2rem; }
  .content { padding: 1.2rem 1rem 5rem; }
  .span-4, .span-5, .span-6 { grid-column: span 12; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .page-head { align-items: start; flex-direction: column; }
  .search { width: 100%; }
  .modal-footer .btn { width: 100%; }
}
