/* DPDPA Vault — tenant staff app. Calm, plain, one brand accent set by the tenant. */
:root {
  color-scheme: light;
  --bg: #F1F4F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;
  --ink: #15202B;
  --muted: #566170;
  --line: #D9DEE4;
  --brand: #1E5AA8;          /* overwritten by tenant theme */
  --brand-ink: #FFFFFF;
  --brand-soft: #E8EFF8;
  --red: #B42318;  --red-bg: #FDEDEB;
  --amber: #8F5600; --amber-bg: #FFF3DC;
  --green: #1D7238; --green-bg: #E6F4EA;
  --focus: #1E5AA8;
  --c-blue: #2563B0;   --c-blue-soft: #E6EFFA;
  --c-teal: #0E7C76;   --c-teal-soft: #DFF3F1;
  --c-violet: #6A4BC4; --c-violet-soft: #EEE9FB;
  --c-amber: #A35D00;  --c-amber-soft: #FFF0D6;
  --c-green: #1D7238;  --c-green-soft: #E2F3E7;
  --c-rose: #B4235A;   --c-rose-soft: #FCE6EE;
  --c-cyan: #0A6F95;   --c-cyan-soft: #DFF1F8;
  --c-indigo: #3F51B5; --c-indigo-soft: #E7E9F8;
  --c-red: #B42318;    --c-red-soft: #FDEBE8;
  --r-tile: 14px; --r-card: 10px; --r-ctl: 7px;
  --rail: 92px;
  --top: 60px;
  --font: "Noto Sans", "Noto Sans Telugu", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12171D; --surface: #1A2129; --surface-2: #1F2731; --ink: #E7ECF1; --muted: #A3AEBB; --line: #2F3944;
    --brand-soft: #1D2B3D; --red: #FF8A7E; --red-bg: #3A1F1D; --amber: #F2B65C; --amber-bg: #3A2D16;
    --green: #6FD08F; --green-bg: #183223; --focus: #8DB7F0;
    --c-blue: #8DB7F0; --c-blue-soft: #1C2A3D; --c-teal: #6FD3CB; --c-teal-soft: #15302E;
    --c-violet: #B7A3F3; --c-violet-soft: #2A2340; --c-amber: #F2B65C; --c-amber-soft: #3A2D16;
    --c-green: #7AD69A; --c-green-soft: #183223; --c-rose: #F49AB9; --c-rose-soft: #3A1E2A;
    --c-cyan: #7CCBEB; --c-cyan-soft: #15303B; --c-indigo: #A9B4F2; --c-indigo-soft: #232A45;
    --c-red: #FF8A7E; --c-red-soft: #3A1F1D;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12171D; --surface: #1A2129; --surface-2: #1F2731; --ink: #E7ECF1; --muted: #A3AEBB; --line: #2F3944;
  --brand-soft: #1D2B3D; --red: #FF8A7E; --red-bg: #3A1F1D; --amber: #F2B65C; --amber-bg: #3A2D16;
  --green: #6FD08F; --green-bg: #183223; --focus: #8DB7F0;
    --c-blue: #8DB7F0; --c-blue-soft: #1C2A3D; --c-teal: #6FD3CB; --c-teal-soft: #15302E;
    --c-violet: #B7A3F3; --c-violet-soft: #2A2340; --c-amber: #F2B65C; --c-amber-soft: #3A2D16;
    --c-green: #7AD69A; --c-green-soft: #183223; --c-rose: #F49AB9; --c-rose-soft: #3A1E2A;
    --c-cyan: #7CCBEB; --c-cyan-soft: #15303B; --c-indigo: #A9B4F2; --c-indigo-soft: #232A45;
    --c-red: #FF8A7E; --c-red-soft: #3A1F1D;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(var(--top) + env(safe-area-inset-top, 0px)); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
:lang(te) body, html[lang="te"] body { line-height: 1.7; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-ctl); z-index: 50; }
.skip:focus { top: 12px; }

/* Top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 20px 0 calc(var(--rail) + 20px);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-badge { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); border: 1px solid currentColor; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; }
.lang button { border: 0; background: transparent; padding: 5px 11px; cursor: pointer; font-size: 14px; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: var(--r-ctl); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: 0 10px 30px rgba(15, 25, 40, .14); padding: 8px; }
.user-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.user-menu button:hover { background: var(--surface-2); }
.user-menu button[aria-current="true"] { font-weight: 600; background: var(--brand-soft); }
.menu-role { margin: 4px 10px 8px; color: var(--muted); font-size: 14px; }
.menu-label { margin: 8px 10px 4px; font-size: 13px; color: var(--muted); }
.menu-demo { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; padding: 4px 0; }

/* Rail */
.rail {
  position: fixed; left: 0; top: env(safe-area-inset-top, 0px); bottom: 0; width: var(--rail); z-index: 25;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: calc(var(--top) + 12px) 8px 12px;
}
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; text-align: center; }
.rail-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.rail-item:hover { background: var(--surface-2); color: var(--ink); }
.rail-item.is-active { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.rail-item.is-active svg { stroke: var(--brand); }

/* Main */
.main { margin-left: var(--rail); padding: 24px 28px 48px; max-width: 1240px; }
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); }

/* Quick actions: the one bold element */
.quick { margin: 22px 0 32px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.05fr); gap: 12px; }
.qa {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left;
  min-height: 132px; padding: 18px; border-radius: var(--r-tile);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.qa:hover { border-color: var(--brand); }
.qa:active { transform: scale(.985); }
.qa-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); }
.qa-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.qa-title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.qa-sub { font-size: 14px; color: var(--muted); line-height: 1.4; margin-top: -4px; }
.qa.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.qa.primary .qa-icon { background: rgba(255,255,255,.18); }
.qa.primary .qa-icon svg { stroke: var(--brand-ink); }
.qa.primary .qa-sub { color: var(--brand-ink); opacity: .85; }
.qa.danger { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.qa.danger:hover { border-color: var(--red); }
.qa.danger .qa-icon { background: var(--surface); }
.qa.danger .qa-icon svg { stroke: var(--red); }
.qa.danger .qa-title { color: var(--red); }

/* Board */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.board-head h2 { font-size: 19px; font-weight: 600; }
.board-tools, .edit-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: var(--r-ctl); cursor: pointer; font-size: 14px; font-weight: 500; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.edit-hint { margin: -4px 0 14px; color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 18px 18px; min-width: 0; position: relative; }
.widget.wide { grid-column: span 2; }
.widget.full { grid-column: 1 / -1; }
.w-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.w-head h3 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; }
.w-tools { display: none; gap: 4px; }
.handle { display: none; cursor: grab; border: 0; background: transparent; padding: 4px 2px; color: var(--muted); touch-action: none; }
.handle svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 3px 7px; cursor: pointer; font-size: 13px; color: var(--muted); line-height: 1.4; }
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn:disabled { opacity: .4; cursor: default; }

.editing .widget { border-style: dashed; border-color: var(--muted); }
.editing .w-tools, .editing .handle { display: flex; }
.editing .w-body { pointer-events: none; opacity: .75; }
.widget.dragging { box-shadow: 0 14px 34px rgba(15, 25, 40, .22); border-style: solid; border-color: var(--brand); opacity: .95; z-index: 5; }
.widget.dragging .handle { cursor: grabbing; }

.tray { margin-top: 18px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--r-card); background: var(--surface-2); }
.tray h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.tray-items { display: flex; gap: 8px; flex-wrap: wrap; }
.tray-items p { margin: 0; color: var(--muted); font-size: 14px; }

/* Widget content */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.stat-n { font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 14px; color: var(--muted); }
.stat.red .stat-n { color: var(--red); }
.stat.amber .stat-n { color: var(--amber); }
.ok { display: flex; align-items: center; gap: 8px; color: var(--green); margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--line); }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); }
.li-main { flex: 1; min-width: 0; }
.li-meta { font-size: 13px; color: var(--muted); }
.li-meta.red { color: var(--red); }
.pill { font-size: 13px; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; align-self: center; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 4px 10px; align-items: center; font-size: 14px; }
.bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }
.bar-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.score { display: flex; align-items: baseline; gap: 10px; }
.score .stat-n { font-size: 36px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; background: var(--green); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.subhead { font-size: 14px; font-weight: 600; margin: 14px 0 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 15px; max-width: calc(100% - 32px); }

/* Tablet */
@media (max-width: 1100px) {
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qa.danger { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; }
  .qa.danger .qa-sub { margin-top: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget.wide { grid-column: 1 / -1; }
}
/* Phone: rail becomes a bottom bar */
@media (max-width: 720px) {
  :root { --rail: 0px; --top: 56px; }
  .topbar { padding: 0 14px; }
  .brand-name { max-width: 40vw; }
  .user-name { display: none; }
  .rail { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); }
  .rail-item { flex: 1; padding: 6px 2px; font-size: 12px; }
  .main { padding: 18px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .page-head h1 { font-size: 22px; }
  .qa { min-height: 112px; padding: 14px; }
  .qa-title { font-size: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .widget.wide, .widget.full { grid-column: auto; }
  .w-tools .size-btn { display: none; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Colour tones: one soft accent per card and quick action */
.tone-blue   { --accent: var(--c-blue);   --accent-soft: var(--c-blue-soft); }
.tone-teal   { --accent: var(--c-teal);   --accent-soft: var(--c-teal-soft); }
.tone-violet { --accent: var(--c-violet); --accent-soft: var(--c-violet-soft); }
.tone-amber  { --accent: var(--c-amber);  --accent-soft: var(--c-amber-soft); }
.tone-green  { --accent: var(--c-green);  --accent-soft: var(--c-green-soft); }
.tone-rose   { --accent: var(--c-rose);   --accent-soft: var(--c-rose-soft); }
.tone-cyan   { --accent: var(--c-cyan);   --accent-soft: var(--c-cyan-soft); }
.tone-indigo { --accent: var(--c-indigo); --accent-soft: var(--c-indigo-soft); }
.tone-red    { --accent: var(--c-red);    --accent-soft: var(--c-red-soft); }

.widget[class*="tone-"] { border-top: 3px solid var(--accent); }
.editing .widget[class*="tone-"] { border-top-style: solid; }
.w-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft, var(--surface-2)); display: grid; place-items: center; flex: none; }
.w-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--accent, var(--muted)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.widget[class*="tone-"] .bar i, .widget[class*="tone-"] .meter i { background: var(--accent); }
.widget[class*="tone-"] .bar { background: var(--accent-soft); border-color: transparent; }
.widget[class*="tone-"] .meter { background: var(--accent-soft); border-color: transparent; }
.widget.tone-green .score .stat-n { color: var(--accent); }

.qa[class*="tone-"] .qa-icon { background: var(--accent-soft); }
.qa[class*="tone-"] .qa-icon svg { stroke: var(--accent); }
.qa[class*="tone-"]:hover { border-color: var(--accent); }

/* Powered by DPDPA Office */
.powered { margin: 40px 0 0; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: center; }
.powered a { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font-size: 13px; }
.powered a:hover .pw-mark b { color: var(--brand); }
.pw-mark { display: inline-flex; align-items: baseline; gap: 3px; color: var(--ink); }
.pw-mark small { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--muted); }
.pw-mark b { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }

/* Sign-in page */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 14px; padding: 28px 26px; }
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.auth-card p { margin: 0 0 12px; color: var(--muted); }
.auth-card p[lang="te"] { color: var(--ink); }
.auth-err { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.auth .powered { margin-top: 24px; border-top: 0; }
