:root {
  --ink: #17201d;
  --muted: #66716d;
  --line: #dfe4e1;
  --surface: #f7f9f8;
  --panel: #ffffff;
  --accent: #087f5b;
  --accent-dark: #066447;
  --accent-soft: #e5f3ee;
  --danger: #b42318;
  --warning: #946200;
  --sidebar: #16201d;
  --radius: 7px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--surface); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.boot-screen { min-height: 100svh; display: grid; place-items: center; color: white; background: var(--sidebar); }
.boot-content { display: grid; justify-items: center; gap: 14px; }
.boot-content strong { font-size: 19px; letter-spacing: 0; }
.boot-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 7px; color: #10201a; background: #66d9ae; font-size: 22px; font-weight: 900; }
.boot-spinner { width: 22px; height: 22px; margin-top: 8px; border: 2px solid rgba(255,255,255,.22); border-top-color: #f6c85f; border-radius: 50%; animation: boot-spin .8s linear infinite; }

.login-shell { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr); background: var(--panel); }
.login-brand { position: relative; overflow: hidden; display: flex; align-items: center; gap: 44px; padding: clamp(40px, 8vw, 120px); background: var(--sidebar); color: white; }
.login-brand::after { content: ""; position: absolute; inset: auto -10% -42% 15%; height: 68%; border-top: 1px solid rgba(255,255,255,.12); transform: rotate(-8deg); }
.brand-mark { width: 112px; height: 112px; flex: 0 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; transform: rotate(45deg); }
.brand-mark span { background: #66d9ae; border-radius: 3px; animation: mark-in .6s ease both; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(5) { background: #f6c85f; }
.brand-mark span:nth-child(3), .brand-mark span:nth-child(4) { background: #f4f7f6; }
.eyebrow { margin: 0 0 12px; color: #8fe1c2; font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.login-brand h1 { margin: 0; font-size: clamp(46px, 6vw, 76px); line-height: 1; letter-spacing: 0; }
.login-copy { margin: 22px 0 0; max-width: 420px; color: #b9c7c2; font-size: 17px; line-height: 1.7; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 48px; }
.login-panel form { width: min(100%, 370px); animation: rise-in .45s ease both; }
.form-heading { margin-bottom: 34px; }
.setup-progress { display: flex; align-items: center; margin-bottom: 28px; color: #9ba5a1; }
.setup-progress span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #cfd7d3; border-radius: 50%; font-size: 11px; font-weight: 800; }
.setup-progress span.done, .setup-progress span.active { color: white; border-color: var(--accent); background: var(--accent); }
.setup-progress i { height: 1px; flex: 1; background: #dce2df; }
.form-heading h2, .modal-header h2 { margin: 0; font-size: 25px; }
.form-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
label { display: grid; gap: 8px; margin: 0 0 18px; color: #3f4945; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cfd7d3; border-radius: var(--radius); padding: 11px 12px; color: var(--ink); background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,127,91,.12); }
.remember-option { display: flex; align-items: center; gap: 9px; width: fit-content; margin-top: -2px; color: var(--muted); cursor: pointer; font-weight: 600; }
.remember-option input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.form-error { min-height: 20px; margin: -4px 0 12px; color: var(--danger); font-size: 13px; }
.primary, .secondary, .danger-button, .text-button { border: 0; border-radius: var(--radius); padding: 10px 14px; font-weight: 700; transition: background .15s, transform .15s; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); }
.primary:active, .secondary:active, .danger-button:active { transform: translateY(1px); }
.wide { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; }
.secondary { background: #edf1ef; color: #26332e; }
.secondary:hover { background: #e1e7e4; }
.danger-button { color: white; background: var(--danger); }
.text-button { padding: 7px 9px; color: var(--muted); background: transparent; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 20px; }
.icon-button:hover { background: rgba(0,0,0,.06); }
.link-button { padding: 0; border: 0; color: var(--accent); background: transparent; font-size: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--accent-dark); }
.login-alt { margin: 18px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 9px; margin: 0; color: #3f4945; font-size: 13px; font-weight: 650; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.switch-track { position: relative; width: 38px; height: 22px; flex: 0 0 auto; border-radius: 11px; background: #cfd7d3; transition: background .18s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(8,127,91,.22); }
.switch input:disabled + .switch-track { opacity: .55; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; color: #e9efec; background: var(--sidebar); }
.sidebar-brand { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.mini-mark { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 5px; color: #10201a; background: #66d9ae; font-weight: 900; }
.nav-list { display: grid; gap: 4px; margin-top: 40px; }
.nav-item { height: 42px; display: flex; align-items: center; gap: 11px; width: 100%; padding: 0 11px; border: 0; border-radius: 6px; color: #aebbb6; background: transparent; text-align: left; font-size: 14px; font-weight: 650; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(102,217,174,.13); }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; font-size: 11px; }
.sidebar-spacer { flex: 1; }
.install-button { height: 40px; display: flex; align-items: center; gap: 10px; margin: 0 5px 12px; padding: 0 11px; border: 1px solid rgba(255,255,255,.12); border-radius: 6px; color: #c8d4cf; background: transparent; font-size: 13px; font-weight: 700; }
.install-button:hover { color: white; background: rgba(255,255,255,.06); }
.account-trigger { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 7px 2px; border: 0; border-top: 1px solid rgba(255,255,255,.1); color: inherit; background: transparent; text-align: left; }
.account-trigger:hover { background: rgba(255,255,255,.05); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #173128; background: #a7d8c6; font-weight: 800; }
.account-copy { min-width: 0; display: grid; flex: 1; }
.account-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.account-copy span { color: #889791; font-size: 11px; margin-top: 2px; }
.account-chevron { color: #7f8d87; font-size: 13px; }
.account-menu { position: fixed; z-index: 18; bottom: 78px; left: 14px; width: 210px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: 0 14px 42px rgba(0,0,0,.2); animation: menu-in .15s ease both; }
.account-menu-header { display: grid; padding: 13px 14px 11px; border-bottom: 1px solid var(--line); }
.account-menu-header strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.account-menu-header span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.account-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 0; color: #34413c; background: white; text-align: left; font-size: 13px; font-weight: 700; }
.account-menu button:hover { background: #f0f4f2; }
.account-menu button span:first-child { width: 18px; color: var(--muted); text-align: center; }
.account-menu .account-menu-danger { color: var(--danger); border-top: 1px solid var(--line); }

.workspace { min-width: 0; }
.mobile-header { display: none; }
.mobile-nav { display: none; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: #84908c; font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: #dce2df; }
.content { max-width: 1400px; margin: 0 auto; padding: 46px clamp(26px, 5vw, 72px) 80px; animation: content-in .3s ease both; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-title h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.page-title p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: #edf1ef; }
.segmented button { border: 0; border-radius: 4px; padding: 7px 12px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.section-line { border-top: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 13px 12px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.data-table td { padding: 16px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.data-table tr { transition: background .15s; }
.data-table tbody tr:hover { background: #f0f4f2; }
.strong-cell { font-weight: 750; }
.sub-cell { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #85908c; }
.status.active { color: #087052; }
.status.active::before { background: #18a074; box-shadow: 0 0 0 3px rgba(24,160,116,.12); }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions button { border: 0; border-radius: 5px; padding: 6px 9px; color: #47524e; background: transparent; font-size: 12px; font-weight: 700; }
.row-actions button:hover { background: #e5eae7; }
.row-actions .delete { color: var(--danger); }
.empty { padding: 72px 20px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; }
.empty strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 16px; }

.codes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.code-item { position: relative; min-height: 184px; display: flex; flex-direction: column; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); transition: border-color .2s, background .2s; }
.code-item:hover { border-color: #b8c6c0; background: #fbfcfb; }
.code-top { display: flex; justify-content: space-between; gap: 18px; }
.code-site { min-width: 0; }
.code-site h2 { margin: 0; overflow-wrap: anywhere; font-size: 17px; }
.code-site p { margin: 5px 0 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.countdown { --progress: 100%; width: 35px; height: 35px; position: relative; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--accent) var(--progress), #e4e9e6 0); font-size: 10px; font-weight: 800; }
.countdown::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: white; }
.countdown span { position: relative; z-index: 1; }
.code-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-top: auto; }
.code-value { font-variant-numeric: tabular-nums; font-size: clamp(27px, 3vw, 35px); font-weight: 800; letter-spacing: .12em; line-height: 1; }
.copy-button { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 6px; color: var(--accent-dark); background: white; font-size: 14px; font-weight: 900; }
.copy-button:hover { border-color: #9ac7b6; background: var(--accent-soft); }
.user-tag { position: absolute; right: 22px; bottom: 7px; color: #8b9591; font-size: 10px; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(8,17,14,.55); animation: fade-in .15s ease both; }
.modal-panel { width: min(100%, 520px); max-height: calc(100vh - 48px); overflow: auto; border-radius: 8px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.22); animation: modal-in .2s ease both; }
.modal-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); background: white; }
.modal-header h2 { font-size: 18px; }
.modal-form { padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.form-help { margin: -8px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 48px)); padding: 11px 15px; border-radius: 6px; color: white; background: #26332e; box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@keyframes mark-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes content-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(5px); } }
@keyframes boot-spin { to { transform: rotate(360deg); } }

@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 34svh; gap: 25px; padding: 34px 28px; }
  .brand-mark { width: 66px; height: 66px; gap: 5px; }
  .login-brand h1 { font-size: 38px; }
  .login-copy { margin-top: 10px; font-size: 14px; }
  .login-panel { align-items: flex-start; padding: 38px 28px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-header { min-height: calc(62px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top) 18px 0; color: white; background: var(--sidebar); }
  .mobile-header .sidebar-brand { padding: 0; }
  .mobile-header .text-button { color: #c8d2ce; }
  .mobile-actions { display: flex; align-items: center; gap: 2px; }
  .mobile-account-trigger { max-width: 170px; display: flex; align-items: center; gap: 6px; padding: 8px 5px 8px 9px; border: 0; color: #e6eeeb; background: transparent; font-size: 13px; font-weight: 700; }
  .mobile-account-trigger span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account-menu { top: calc(56px + env(safe-area-inset-top)); right: 12px; bottom: auto; left: auto; width: min(210px, calc(100vw - 24px)); }
  .content { padding: 30px 18px calc(42px + env(safe-area-inset-bottom)); }
  .app-shell.has-mobile-nav .content { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-title h1 { font-size: 25px; }
  .page-title p { line-height: 1.55; }
  .toolbar { width: 100%; flex-wrap: wrap; }
  .toolbar > .primary { margin-left: auto; }
  .mobile-table, .mobile-table tbody, .mobile-table tr, .mobile-table td { display: block; width: 100%; }
  .mobile-table thead { display: none; }
  .mobile-table tr { position: relative; padding: 17px 0; border-bottom: 1px solid var(--line); }
  .mobile-table td { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 6px 2px; border: 0; text-align: right; }
  .mobile-table td::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
  .mobile-table td:first-child { display: block; padding: 0 2px 12px; text-align: left; font-size: 16px; }
  .mobile-table td:first-child::before, .mobile-table td:last-child::before { display: none; }
  .mobile-table td:last-child { display: block; padding: 9px 0 0; }
  .mobile-table .row-actions { justify-content: flex-start; }
  .mobile-table .row-actions button { padding: 8px 10px; background: #e9eeeb; }
  .codes-grid { grid-template-columns: 1fr; gap: 12px; }
  .code-item { min-height: 184px; }
  .mobile-nav { position: fixed; z-index: 12; right: 0; bottom: 0; left: 0; min-height: calc(66px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr; padding: 7px 18px env(safe-area-inset-bottom); border-top: 1px solid #29332f; color: #aebbb6; background: rgba(22,32,29,.98); backdrop-filter: blur(14px); }
  .mobile-nav.passkey-enabled, .mobile-nav.admin { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav.admin.passkey-enabled { grid-template-columns: repeat(3, 1fr); }
  .mobile-nav-item { display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; color: inherit; background: transparent; font-size: 11px; font-weight: 700; }
  .mobile-nav-item.active { color: #7be0b9; }
  .mobile-nav-icon { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 5px; font-size: 11px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal-panel { width: 100%; max-height: calc(92svh - env(safe-area-inset-top)); border-radius: 8px 8px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .toast { right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); left: 18px; max-width: none; text-align: center; }
  .app-shell.has-mobile-nav .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
