:root {
  --navy: #081726;
  --ink: #132743;
  --blue: #1A6FB5;
  --blue-dark: #145D99;
  --red: #C4272C;
  --teal: #0E9F9A;
  --orange: #F59E0B;
  --green: #16A34A;
  --mute: #64748B;
  --line: #E2E8F0;
  --bg: #F2F4F8;
  --card: #FFFFFF;
  --text: #0F172A;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 15px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 600; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 18px; }
.brand .mini-logo { width: 30px; height: 30px; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.78); font-weight: 600; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.sidebar .me { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.main { flex: 1; min-width: 0; padding: 26px 32px 80px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stack > * + * { margin-top: 16px; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: auto; height: auto;
    flex-direction: row; padding: 6px; z-index: 50;
  }
  .brand, .sidebar .me { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; }
  .main { padding: 18px 14px 90px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid rgba(15,23,42,.06); padding: 16px; }
.card.flush { padding: 4px 16px; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: #F8FAFC; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.empty { color: var(--mute); padding: 14px 0; font-size: 14px; }
.stat .num { font-size: 30px; font-weight: 800; }
.stat .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; }
.date-box { width: 48px; text-align: center; border-radius: 10px; padding: 4px 0; flex-shrink: 0; }
.date-box .m { font-size: 11px; font-weight: 800; }
.date-box .d { font-size: 19px; font-weight: 800; }
.kind-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-size: 18px; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Buttons & inputs ---------- */
button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 10px; padding: 9px 14px; font-weight: 600;
  background: #E8EEF6; color: var(--blue-dark); display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { filter: brightness(.97); text-decoration: none; }
button.primary, .btn.primary { background: var(--blue); color: #fff; }
button.danger { background: #FDECEC; color: var(--red); }
button.ghost { background: transparent; color: var(--blue); padding: 6px 8px; }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #CBD5E1; border-radius: 10px; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26,111,181,.35); border-color: var(--blue); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 500; }
.check input { width: auto; }
.seg { display: inline-flex; background: #E2E8F0; border-radius: 10px; padding: 3px; }
.seg button { background: transparent; color: var(--text); padding: 6px 14px; }
.seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--mute); border-radius: 0; border-bottom: 2px solid transparent; padding: 10px 12px; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick a, .quick span { text-align: center; padding: 10px; border-radius: 12px; background: #E8F1FA; font-weight: 600; font-size: 13px; color: var(--blue); }
.quick span { opacity: .4; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,23,38,.45); display: flex; justify-content: center; align-items: flex-start; padding: 40px 14px; overflow-y: auto; z-index: 100; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; border-radius: 18px 18px 0 0; z-index: 2; }
.modal-body { padding: 18px 20px; }
.modal fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 16px; }
.modal legend { font-weight: 700; padding: 0 6px; }
.multi-row { display: grid; grid-template-columns: 130px 1fr 34px; gap: 8px; margin-bottom: 8px; }
.addr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.person-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 34px; gap: 8px; margin-bottom: 8px; }
.person-row .wide { grid-column: 1 / -2; }
@media (max-width: 600px) {
  .multi-row { grid-template-columns: 100px 1fr 34px; }
  .person-row { grid-template-columns: 1fr 34px; }
  .person-row .wide { grid-column: 1 / -2; }
}

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--mute); padding: 4px 0; }
.cal-day { min-height: 92px; border-radius: 10px; padding: 6px; background: #F8FAFC; cursor: pointer; overflow: hidden; border: 2px solid transparent; }
.cal-day:hover { background: #EEF4FB; }
.cal-day.blank { background: transparent; cursor: default; }
.cal-day.sel { border-color: var(--blue); }
.cal-day.today .n { background: var(--blue); color: #fff; }
.cal-day.overdue { background: #FDF1F1; }
.cal-day .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 700; font-size: 13px; }
.cal-ev { font-size: 11px; padding: 2px 5px; border-radius: 5px; color: #fff; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .cal-day { min-height: 54px; } .cal-ev { font-size: 0; height: 6px; padding: 0; } }

/* ---------- Bars chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; }
.bar-seg { border-radius: 4px 4px 0 0; }
.bar-label { text-align: center; font-size: 11px; color: var(--mute); margin-top: 4px; }

/* ---------- Toast ---------- */
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.2); cursor: pointer; max-width: 90vw; }
.toast.error { background: var(--red); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; text-align: center; }
.login .logos { display: flex; gap: 16px; justify-content: center; margin-bottom: 14px; }
.login form { text-align: left; margin-top: 18px; }

/* ---------- Brand logo ---------- */
.logo { display: grid; place-items: center; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo .badge { width: 100%; height: 100%; border-radius: 22%; display: grid; place-items: center; color: #fff; font-weight: 800; text-align: center; line-height: 1.05; }

/* ---------- Splash ---------- */
.splash { position: fixed; inset: 0; z-index: 1000; background: linear-gradient(var(--navy), var(--ink)); display: grid; place-items: center; overflow: hidden; transition: opacity .35s ease-in; }
.splash.fade { opacity: 0; }
.splash-logos { display: flex; gap: 28px; }
.splash-logo { width: 140px; height: 140px; position: relative; transform: translateY(-110vh); }
.splash-logo.drop { animation: drop-bounce 1.9s forwards; }
.splash-logo.drop.late { animation-delay: .16s; }
.splash-logo.shake { animation: shake .06s 7 alternate; transform: none; }
.splash-logo.gone { transform: none; }
.splash-logo.gone > .logo { visibility: hidden; }
.shard { position: absolute; inset: 0; transition-property: transform, opacity; transition-timing-function: cubic-bezier(.15,.7,.3,1); }
.spark { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 50%; transition: transform 1s cubic-bezier(.15,.7,.3,1), opacity 1s ease-in; }
.flash { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: #fff; transform: scale(.01); opacity: .9; transition: transform .7s ease-out, opacity .7s ease-out; }
.flash.go { transform: scale(18); opacity: 0; }
.splash-title { position: absolute; text-align: center; color: #fff; opacity: 0; transform: scale(.6); transition: all .5s cubic-bezier(.3,1.6,.5,1); }
.splash-title.show { opacity: 1; transform: none; }
.app-name { font-size: 32px; font-weight: 900; }
.app-sub { opacity: .75; font-weight: 600; margin-top: 4px; }
@keyframes drop-bounce {
  0%   { transform: translateY(-110vh); animation-timing-function: ease-in; }
  24%  { transform: translateY(0) scale(1.12, .86); animation-timing-function: ease-out; }
  27%  { transform: translateY(0); animation-timing-function: ease-out; }
  48%  { transform: translateY(-100px); animation-timing-function: ease-in; }
  68%  { transform: translateY(0) scale(1.1, .88); animation-timing-function: ease-out; }
  70%  { transform: translateY(0); animation-timing-function: ease-out; }
  81%  { transform: translateY(-40px); animation-timing-function: ease-in; }
  91%  { transform: translateY(0) scale(1.06, .94); animation-timing-function: ease-out; }
  95%  { transform: translateY(-12px); animation-timing-function: ease-in; }
  100% { transform: translateY(0); }
}
@keyframes shake { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@media (prefers-reduced-motion: reduce) {
  .splash-logo { transform: none; }
  .splash-logo.drop { animation: none; }
}
