:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1c2330; --muted: #667085; --line: #e3e6ec;
  --field-bg: #eff4fa; --field-line: #cfd8e6; --locked-bg: #f4f6f9;
  --brand: #2f5bea; --brand-d: #2447c0; --ok: #137a4b; --warn: #b54708; --bad: #b42318; --chip: #eef1f7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --field-bg: #222b3b; --field-line: #3a465c; --locked-bg: #1d2431;
    --bg: #11151c; --panel: #1a202b; --text: #e8ecf3; --muted: #9aa5b8; --line: #2a3140;
    --brand: #6f8dff; --brand-d: #8aa2ff; --ok: #4ad295; --warn: #f5a35c; --bad: #ff7b72; --chip: #252d3b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 17px; margin: 0 0 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; padding: 4px 10px 14px; font-size: 16px; }
.side a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.side a:hover { background: var(--chip); } .side a.on { background: var(--brand); color: #fff; }
.side .sep { margin: 12px 12px 4px; color: var(--muted); font-size: 12px; }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; }
.main { padding: 22px 28px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .who { color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.bar input, .bar select { max-width: 240px; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--chip); }
.btn.danger { background: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input, select, textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--chip); }
.table-wrap { overflow-x: auto; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 10px; font-size: 13px; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }
.muted { color: var(--muted); } .empty { color: var(--muted); padding: 18px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kv .k { color: var(--muted); font-size: 13px; } .kv .v { font-weight: 600; word-break: break-word; }
label.f { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.f > :not(span) { margin-top: 4px; color: var(--text); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 8px; }
.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; }
.toast.err { background: var(--bad); color: #fff; }
.progress { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--brand); }
.login { max-width: 360px; margin: 14vh auto; }
.login .card { padding: 24px; }
.err-text { color: var(--bad); margin: 8px 0; }
.unread { font-weight: 700; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .side .sep, .brand { width: 100%; }
  .main { padding: 14px 16px; }
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.bell { position: relative; }
.shell.topmode { display: block; }
.topnav { display: flex; align-items: center; gap: 2px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 16px; overflow-x: auto; position: sticky; top: 0; z-index: 5; }
.topnav .brand { font-weight: 700; padding: 0 12px 0 20px; white-space: nowrap; }
.topnav a { color: var(--text); padding: 14px 14px; border-bottom: 3px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.topnav a:hover { background: var(--chip); }
.topnav a.on { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }
.topnav .grow { flex: 1; }
.subnav { display: flex; gap: 6px; background: var(--brand); padding: 8px 16px; overflow-x: auto; }
.subnav a { color: #fff; padding: 6px 14px; border-radius: 8px; white-space: nowrap; opacity: .9; }
.subnav a:hover { background: rgba(255,255,255,.18); opacity: 1; }
.subnav a.on { background: rgba(255,255,255,.28); opacity: 1; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .subnav { background: #2a3a78; } }

.idline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.idline code { background: var(--chip); border-radius: 6px; padding: 2px 8px; direction: ltr; word-break: break-all; }
.btn.sm { padding: 3px 10px; font-size: 13px; }

.kv .v { white-space: pre-wrap; }
.v.editing { padding: 0; margin: 0; }
.v.editing input, .v.editing select, .v.editing textarea { font-weight: 400; }
.inline-select { width: auto; padding: 3px 8px; }
.v.locked::before { content: '🔒 '; font-size: 12px; opacity: .6; }

button.tab { background: none; border: 0; border-bottom: 2px solid transparent; font: inherit; cursor: pointer; }
.code { background: var(--chip); border-radius: 6px; padding: 2px 8px; direction: ltr; display: inline-block; word-break: break-all; font-weight: 400; }
.tabpanel { min-height: 120px; }

/* Field boxes: bold label above, the value sits inside a visible box */
.grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.fkv .k { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.fkv .v { font-weight: 400; background: var(--field-bg); border: 1px solid var(--field-line); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; display: flex; align-items: center; gap: 8px; margin-inline-start: 0; }
.fkv .v.editable { cursor: text; }
.fkv .v.editable:hover, .fkv .v.editable:focus-visible { border-color: var(--brand); background: var(--field-bg); }
.fkv .v.locked { background: var(--locked-bg); color: var(--muted); }
.fkv .v.editing { padding: 0; border-color: var(--brand); }
.fkv .v.editing input, .fkv .v.editing select, .fkv .v.editing textarea { border: 0; background: transparent; padding: 10px 14px; min-height: 42px; }
.fkv.wide { grid-column: span 2; }
.fkv[data-type=textarea] .v { min-height: 150px; align-items: flex-start; }
.fkv[data-type=textarea] .v.editing textarea { min-height: 148px; height: 100%; }
.fkv[data-type]:not([data-type=text]):not([data-type=textarea]):not([data-type=number]):not([data-type=locked]) .v::after { margin-inline-start: auto; opacity: .55; font-size: 14px; }
.fkv[data-type=tel] .v::after { content: '📞'; }
.fkv[data-type=email] .v::after { content: '✉️'; }
.fkv[data-type=date] .v::after { content: '📅'; }
.fkv[data-type=url] .v::after { content: '🔗'; }
.fkv[data-type=select] .v::after { content: '▾'; }
.fkv .v.editing::after { content: none !important; }
@media (max-width: 760px) { .fkv.wide { grid-column: auto; } }

.rowcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--panel); }
.rowcard.new { border-color: var(--brand); }
.rowhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; gap: 10px; }

.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cols2 > .col { min-width: 0; display: flex; flex-direction: column; }
@media (max-width: 980px) { .cols2 { grid-template-columns: 1fr; } }
.grouphead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.grouphead h2 { margin: 0; }
.layout-select { width: auto; font-size: 13px; padding: 3px 8px; color: var(--muted); }
.grid[data-cols="1"] .fkv.wide { grid-column: auto; }

.idrow { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fkv .v:has(.idrow) { height: auto; }

.fkv[data-type=files] .v { align-items: center; padding-block: 6px; }
.filebox { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; width: 100%; flex-wrap: wrap; }
.filelist { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.addfile { flex: none; }
.linklike { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; text-align: start; }
.linklike:hover { text-decoration: underline; }

.modal.wide { width: min(1000px, 100%); }
.previewimg { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto 12px; }
.previewframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.previewtext { max-height: 60vh; overflow: auto; direction: auto; white-space: pre-wrap; word-break: break-word; background: var(--field-bg); border: 1px solid var(--field-line); border-radius: 8px; padding: 12px; margin: 0 0 12px; font-size: 13px; }

.secret { letter-spacing: 1px; direction: ltr; }
.secrettools { margin-inline-start: auto; display: inline-flex; gap: 4px; }
.iconbtn { background: none; border: 0; cursor: pointer; font-size: 15px; padding: 2px 4px; border-radius: 6px; }
.iconbtn:hover { background: var(--chip); }
.fkv[data-type=secret] .v { gap: 8px; }

.formgrid { display: grid; gap: 12px; }
.grid[data-group="passwords:entries"] .fkv.wide { grid-column: auto; }
.grid[data-group="passwords:entries"] .fkv[data-type=textarea] .v { min-height: 44px; }
@media (max-width: 900px) { .grid[data-cols], .formgrid { grid-template-columns: 1fr !important; } }

/* work timer in the navigation */
.timerbox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; margin: 4px 0; }
.topnav .timerbox { flex-wrap: nowrap; padding: 4px 12px; margin: 0; white-space: nowrap; }
.timerbox .timer-link, .timerbox .timer-task { padding: 0; border-bottom: 0; display: inline; }
.timerbox .timer-task { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.timer-live { display: flex; align-items: center; gap: 6px; }
.timer-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; direction: ltr; }
.timer-time.paused { color: var(--warn); }
.timer-btns { display: flex; gap: 6px; }
.timerbox .btn { padding: 4px 10px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.timer-info { background: var(--chip); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.timer-info-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.timer-start-at { font-size: 12px; }
/* recycle bin: the link sits at the left edge of the bar (RTL: the end side); the bulk bar shows only while rows are chosen */
.bin-link { margin-inline-start: auto; }
.btn.ghost.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.ghost.danger:hover { background: var(--bad); color: #fff; }
.bulkbar { background: var(--chip); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.bulkbar[hidden] { display: none; }
.bulkcount { font-weight: 600; margin-inline-end: 4px; }
/* project page: short text fields that stand alone in a group take the full row */
.grid[data-group="projects:initial"] .fkv[data-type=text] { grid-column: 1 / -1; }
/* multi-select: a list of options; the selected ones are outlined */
.multibox { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; width: 100%; padding: 4px; }
.multibox .opt { padding: 9px 14px; border: 2px solid transparent; border-radius: 10px; background: var(--field-bg); cursor: pointer; user-select: none; }
.multibox .opt:hover { border-color: var(--field-line); }
.multibox .opt.on { border-color: var(--brand); background: var(--chip); font-weight: 600; }
.multibox .opt:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fkv .v.editing:has(.multibox) { border: 0; background: transparent; }
