/* ============ Director Expenses — mobile app styles ============ */
:root {
  --grad: linear-gradient(135deg, #1e40af 0%, #2563eb 48%, #06b6d4 100%);
  --grad-soft: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-ink: #ffffff;
  --accent: #06b6d4;
  --bg: #f1f5fd;
  --surface: #ffffff;
  --surface-2: #f5f8ff;
  --surface-3: #e9effc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e3e9f5;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --success: #10b981;
  --success-soft: #d1fae5;
  --warn: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(37, 99, 235, .06);
  --shadow: 0 12px 32px -14px rgba(37, 99, 235, .35);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .45);
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
[data-theme="dark"] {
  --grad: linear-gradient(135deg, #172554 0%, #1d4ed8 52%, #0e7490 100%);
  --grad-soft: linear-gradient(135deg, #172554 0%, #0c4a6e 100%);
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --bg: #070d1a;
  --surface: #0f172a;
  --surface-2: #131d35;
  --surface-3: #1b2744;
  --text: #e8eefc;
  --text-2: #c5d0e6;
  --muted: #8896b3;
  --border: #1f2b47;
  --danger-soft: rgba(239, 68, 68, .16);
  --success-soft: rgba(16, 185, 129, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 12px 32px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  transition: background .3s, color .3s;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.ic { width: 22px; height: 22px; flex: none; display: block; }
.ic.sm { width: 18px; height: 18px; }
.ic.xs { width: 15px; height: 15px; }
.ic.lg { width: 28px; height: 28px; }

/* ---------- Splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--grad);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; overflow: hidden;
  transition: opacity .5s ease, visibility .5s;
}
#splash.out { opacity: 0; visibility: hidden; }
.splash-glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(125, 211, 252, .45), transparent 65%);
  animation: glow 3s ease-in-out infinite;
}
.splash-logo { width: 96px; height: 96px; position: relative; animation: pop .8s cubic-bezier(.2, 1.4, .4, 1) both; }
.splash-logo svg { width: 100%; height: 100%; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .25)); }
.splash-title { margin-top: 22px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; position: relative; animation: rise .7s .15s both; }
.splash-sub { opacity: .8; margin-top: 4px; font-size: 14px; position: relative; animation: rise .7s .25s both; }
.splash-bar { margin-top: 34px; width: 150px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .25); overflow: hidden; position: relative; }
.splash-bar span { position: absolute; inset: 0; width: 40%; border-radius: 9px; background: #fff; animation: load 1.1s ease-in-out infinite; }
@keyframes glow { 50% { transform: scale(1.15); opacity: .7; } }
@keyframes pop { from { transform: scale(.4) rotate(-10deg); opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
@keyframes load { 0% { left: -40%; } 100% { left: 100%; } }

/* ---------- App shell ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.view { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 90px); animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

/* Hero / top headers */
.hero {
  background: var(--grad); color: #fff;
  padding: calc(18px + var(--safe-t)) 20px 64px;
  border-radius: 0 0 30px 30px;
  position: relative; overflow: hidden;
}
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09); pointer-events: none;
}
.hero::before { width: 240px; height: 240px; right: -70px; top: -90px; }
.hero::after { width: 160px; height: 160px; left: -50px; bottom: -80px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.hero .hello { opacity: .85; font-size: 13.5px; font-weight: 500; }
.hero h1 { font-size: 24px; font-weight: 800; }
.hero-sub { opacity: .85; font-size: 13px; margin-top: 2px; }
.glass-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .2); transition: transform .15s, background .2s;
}
.glass-btn:active { transform: scale(.92); background: rgba(255, 255, 255, .28); }
.hero-card {
  position: relative; z-index: 1; margin-top: 20px; padding: 18px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 20px; backdrop-filter: blur(10px);
}
.hero-card .label { font-size: 12.5px; opacity: .85; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero-card .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; word-break: break-word; }
.hero-card .stats { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; opacity: .92; flex-wrap: wrap; }
.hero-card .stats span { display: inline-flex; align-items: center; gap: 6px; }

.overlap { margin-top: -42px; position: relative; z-index: 2; padding: 0 16px; }

/* Topbar for inner pages */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--safe-t)) 14px 12px;
  background: var(--grad); color: #fff;
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .glass-btn { width: 40px; height: 40px; border-radius: 13px; }

/* Sections */
.section { padding: 18px 16px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.link-btn { color: var(--primary); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; padding: 6px 4px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.card.pad { padding: 16px; }
.list { display: flex; flex-direction: column; gap: 10px; }

/* Company card */
.co-card {
  display: flex; align-items: center; gap: 14px; padding: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .2s;
  animation: fadeIn .3s ease both;
}
.co-card:active { transform: scale(.98); }
.avatar {
  width: 50px; height: 50px; border-radius: 16px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px;
  background: var(--grad); box-shadow: var(--shadow);
}
.co-info { flex: 1; min-width: 0; }
.co-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.co-amt { text-align: right; }
.co-amt b { display: block; font-size: 14.5px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.co-amt small { color: var(--muted); font-size: 11.5px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); flex: none;
  transition: background .15s;
}
.icon-btn:active { background: var(--surface-3); }

/* Empty state */
.empty { text-align: center; padding: 40px 24px; color: var(--muted); }
.empty .em-ic {
  width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--grad-soft); color: var(--primary); font-size: 38px;
}
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty p { margin: 0 0 18px; font-size: 14px; }

/* Skeleton */
.skel { border-radius: var(--radius); height: 78px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-3) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--border); }
.skel.sm { height: 64px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 20px; border-radius: 15px; font-weight: 700; font-size: 15px;
  background: var(--surface-3); color: var(--text); transition: transform .12s, filter .2s, opacity .2s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: var(--shadow); }
.btn.success { background: linear-gradient(135deg, #059669, #10b981); color: #fff; box-shadow: 0 12px 28px -14px rgba(16, 185, 129, .7); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.block { width: 100%; }
.btn.sm { height: 40px; border-radius: 12px; padding: 0 14px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* FAB */
.fab {
  position: fixed; z-index: 30;
  right: max(18px, calc(50vw - 280px + 18px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  height: 58px; min-width: 58px; padding: 0 22px; border-radius: 20px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 16px 34px -10px rgba(37, 99, 235, .7);
  transition: transform .15s; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.fab:active { transform: scale(.93); }

/* Tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 40;
  width: 100%; max-width: 560px;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative;
}
.tab .tab-ic { width: 46px; height: 30px; border-radius: 12px; display: grid; place-items: center; transition: background .2s, color .2s; }
.tab.active { color: var(--primary); }
.tab.active .tab-ic { background: var(--grad); color: #fff; box-shadow: var(--shadow); }

/* Forms */
.field { margin-bottom: 14px; }
.field > label, .label-sm { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 0 7px 2px; text-transform: uppercase; letter-spacing: .05em; }
.input, select.input, textarea.input {
  width: 100%; height: 50px; padding: 0 15px; border-radius: 14px;
  background: var(--surface-2); border: 1.5px solid var(--border); outline: none;
  transition: border .15s, box-shadow .15s, background .15s; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
textarea.input { height: auto; min-height: 84px; padding: 13px 15px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); background: var(--surface); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .input { padding-left: 44px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="date"].input { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; }

.amount-box {
  display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-radius: 20px;
  background: var(--grad); color: #fff; margin-bottom: 18px; box-shadow: var(--shadow);
}
.amount-box .cur { font-weight: 800; font-size: 16px; opacity: .85; }
.amount-box input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #fff;
  font-size: 34px; font-weight: 800; letter-spacing: -.02em;
}
.amount-box input::placeholder { color: rgba(255, 255, 255, .55); }

/* Category picker */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cat-chip {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 6px;
  border-radius: 15px; background: var(--surface-2); border: 1.5px solid var(--border);
  font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; transition: all .15s;
}
.cat-chip .emo { font-size: 22px; line-height: 1; }
.cat-chip.sel { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.cat-chip:active { transform: scale(.95); }

/* Chips row */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.chip.sel { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow); }
.hero .chip { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .25); color: #fff; }
.hero .chip.sel { background: #fff; color: var(--primary-600); }
.quick { display: flex; gap: 6px; margin-top: 8px; }
.quick .chip { height: 30px; font-size: 12.5px; padding: 0 12px; }

/* Expense rows */
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.day-head b { color: var(--text-2); }
.swipe { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; animation: fadeIn .3s ease both; }
.swipe-actions { position: absolute; inset: 0; display: flex; justify-content: flex-end; background: var(--danger); border-radius: var(--radius); }
.swipe-actions button { width: 88px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 700; }
.swipe-inner { position: relative; transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.swipe.open .swipe-inner { transform: translateX(-88px); }
.exp-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.bubble {
  width: 46px; height: 46px; border-radius: 15px; flex: none; display: grid; place-items: center; font-size: 21px;
  background: color-mix(in srgb, var(--c, #2563eb) 15%, var(--surface)); position: relative; overflow: hidden;
}
.bubble img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bubble .badge-emo { position: absolute; right: 1px; bottom: 1px; font-size: 12px; background: var(--surface); border-radius: 7px; padding: 1px 2px; line-height: 1; }
.bubble.lg { width: 60px; height: 60px; border-radius: 20px; font-size: 28px; }
.exp-main { flex: 1; min-width: 0; }
.exp-title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-sub { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.exp-amt { font-weight: 800; font-size: 15px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.pill.blue { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.pill.green { background: var(--success-soft); color: var(--success); }
.pill.red { background: var(--danger-soft); color: var(--danger); }

/* Search */
.search { margin: 14px 0 6px; }

/* Settings list */
.group { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.group + .group-title { margin-top: 22px; }
.group-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 22px 6px 8px; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%; text-align: left; color: inherit; }
.item + .item { border-top: 1px solid var(--border); }
.item .it-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, #2563eb) 14%, transparent); color: var(--c, var(--primary)); flex: none; }
.item .it-main { flex: 1; min-width: 0; }
.item .it-title { font-weight: 650; }
.item .it-sub { font-size: 12.5px; color: var(--muted); }
.item .chev { color: var(--muted); }
.item:active:not(.static) { background: var(--surface-2); }

/* Switch */
.switch { position: relative; width: 52px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border); transition: .25s; }
.switch span::after { content: ''; position: absolute; width: 25px; height: 25px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: .25s cubic-bezier(.3, 1.4, .5, 1); }
.switch input:checked + span { background: var(--grad); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(21px); }

/* Bottom sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, .5); opacity: 0; transition: opacity .28s; backdrop-filter: blur(2px); }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 8px 18px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .34s cubic-bezier(.2, .9, .25, 1);
  box-shadow: var(--shadow-lg); overscroll-behavior: contain;
}
.sheet.full { height: 94vh; height: 94dvh; max-height: none; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-handle { width: 42px; height: 5px; border-radius: 9px; background: var(--border); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 20px; font-weight: 800; }
.sheet-close { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.sheet-wrap.dialog { align-items: center; padding: 20px; }
.sheet-wrap.dialog .sheet { border-radius: 24px; transform: scale(.9); opacity: 0; transition: transform .22s, opacity .22s; padding: 22px; max-width: 400px; }
.sheet-wrap.dialog.open .sheet { transform: none; opacity: 1; }
.dialog-ic { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 12px; background: var(--danger-soft); color: var(--danger); }
.dialog-ic.info { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.dialog h3 { font-size: 19px; margin-bottom: 6px; }
.dialog p { margin: 0 0 20px; color: var(--muted); }

.action-list { display: flex; flex-direction: column; gap: 6px; }
.action { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 15px; font-weight: 650; width: 100%; text-align: left; background: var(--surface-2); }
.action:active { background: var(--surface-3); }
.action.danger { color: var(--danger); }

/* Detail sheet */
.detail-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-amount { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.kv { background: var(--surface-2); border-radius: 16px; padding: 4px 14px; margin-bottom: 16px; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; }
.kv > div + div { border-top: 1px solid var(--border); }
.kv span { color: var(--muted); font-size: 13.5px; flex: none; }
.kv b { font-weight: 650; text-align: right; word-break: break-word; white-space: pre-wrap; }

/* Attachments */
.att-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.att {
  position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted);
  font-size: 11px; text-align: center; padding: 6px; border: 1px solid var(--border);
}
.att img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.att .pdf-ic { color: #ef4444; }
.att .att-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att .att-x {
  position: absolute; top: 5px; right: 5px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(15, 23, 42, .7); color: #fff; display: grid; place-items: center;
}
.att .att-new { position: absolute; left: 5px; top: 5px; z-index: 2; }
.upload-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.upload-btn {
  height: 74px; border-radius: 16px; border: 1.8px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface)); color: var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 700; font-size: 13px;
}
.upload-btn:active { transform: scale(.97); }
.progress { margin: 4px 0 14px; }
.progress .track { height: 8px; border-radius: 9px; background: var(--surface-3); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--grad); border-radius: 9px; transition: width .2s; }
.progress .ptext { font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 200; background: rgba(2, 6, 23, .96); display: flex; flex-direction: column; animation: fadeIn .2s; }
.viewer-bar { display: flex; gap: 8px; padding: calc(12px + var(--safe-t)) 12px 12px; justify-content: space-between; }
.viewer-bar .grp { display: flex; gap: 8px; }
.viewer-img { flex: 1; display: grid; place-items: center; overflow: auto; padding: 8px; touch-action: pinch-zoom; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer-cap { color: #cbd5e1; text-align: center; padding: 10px 16px calc(16px + var(--safe-b)); font-size: 13px; }

/* Stats bars */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; gap: 10px; }
.bar-row .top b { white-space: nowrap; }
.bar-row .track { height: 8px; border-radius: 9px; background: var(--surface-3); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 9px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat .s-l { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat .s-v { font-size: 17px; font-weight: 800; margin-top: 2px; word-break: break-word; }
.stat.main { grid-column: 1 / -1; background: var(--grad); color: #fff; }
.stat.main .s-l { color: rgba(255, 255, 255, .85); }
.stat.main .s-v { font-size: 26px; }

/* Emoji + colour pickers */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 11px; font-size: 21px; background: var(--surface-2); border: 1.5px solid transparent; }
.emoji-grid button.sel { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.color-row button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border); }
.color-row button.sel { box-shadow: 0 0 0 2.5px var(--text); }

/* Login */
.login {
  min-height: 100vh; min-height: 100dvh; background: var(--grad); display: flex; flex-direction: column;
  justify-content: flex-end; position: relative; overflow: hidden;
}
.login::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(125, 211, 252, .4), transparent 65%); top: -120px; right: -140px; }
.login-brand { color: #fff; padding: 40px 28px 30px; position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.login-brand .logo { width: 72px; height: 72px; margin-bottom: 18px; }
.login-brand h1 { font-size: 32px; font-weight: 800; line-height: 1.1; }
.login-brand p { opacity: .85; margin: 8px 0 0; }
.login-card { background: var(--surface); border-radius: 30px 30px 0 0; padding: 28px 22px calc(28px + var(--safe-b)); position: relative; animation: rise .5s ease both; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-card .muted { margin: 0 0 20px; }

/* Toasts */
#toasts { position: fixed; z-index: 300; left: 0; right: 0; top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 480px; width: fit-content; padding: 12px 16px; border-radius: 15px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.2, 1.3, .4, 1) both;
}
.toast.ok { background: #059669; color: #fff; }
.toast.err { background: #dc2626; color: #fff; }
.toast.out { animation: toastOut .25s ease both; }
@keyframes toastIn { from { transform: translateY(-20px) scale(.95); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-20px); opacity: 0; } }

.info-box { background: var(--grad-soft); border-radius: 16px; padding: 14px 16px; font-size: 13.5px; color: var(--text-2); margin-bottom: 16px; }
.info-box ol { margin: 6px 0 0; padding-left: 20px; }
.info-box li { margin: 3px 0; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--danger); }
.status-dot.on { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }

@media (min-width: 600px) {
  body { background: radial-gradient(ellipse at top, color-mix(in srgb, var(--primary) 12%, var(--bg)), var(--bg) 60%); }
  #app { box-shadow: 0 0 0 1px var(--border); background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
