/* Themes: light (default), dark, gold. "auto" follows the device setting. Chosen in the header, kept in the browser. */
:root {
  --bg: #f4f6f5; --panel: #fff; --ink: #14201c; --muted: #5d6b66; --line: #dbe2df;
  --accent: #0b6e4f; --accent-ink: #fff; --accent2: #c9820a; --danger: #b3261e; --ok: #0b6e4f;
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #101614; --panel: #18211e; --ink: #e8efec; --muted: #9aaaa4; --line: #2b3733;
          --accent: #4fd1a1; --accent-ink: #06231a; --accent2: #e0a33a; --danger: #ff8a80; --ok: #4fd1a1; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #101614; --panel: #18211e; --ink: #e8efec; --muted: #9aaaa4; --line: #2b3733;
          --accent: #4fd1a1; --accent-ink: #06231a; --accent2: #e0a33a; --danger: #ff8a80; --ok: #4fd1a1; color-scheme: dark; }
:root[data-theme="gold"] { --bg: #0e0c08; --panel: #1a160e; --ink: #f4ecd8; --muted: #b3a585; --line: #3a301c;
          --accent: #d9b24c; --accent-ink: #1c1503; --accent2: #59c2d6; --danger: #ff9a8a; --ok: #e6c768; color-scheme: dark; }
:root[data-theme="gold"] h1, :root[data-theme="gold"] .brand { color: #ecd28a; }
:root[data-theme="gold"] .primary { background: linear-gradient(180deg, #e6c463, #c79a2e); }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: var(--accent); }
code { background: var(--line); padding: 1px 6px; border-radius: 4px; font-size: .9em; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
       padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); text-decoration: none; }
.mark { width: 18px; height: 18px; border-radius: 5px 5px 5px 0; background: var(--accent); }
#who { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: .92rem; }

main { max-width: 880px; margin: 0 auto; padding: 28px 16px 60px; }
.card { max-width: 440px; margin: 4vh auto 0; background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 28px; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }
.alt { margin: 18px 0 0; font-size: .92rem; color: var(--muted); }

form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
label { display: grid; gap: 5px; font-size: .88rem; font-weight: 550; }
input { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
        border-radius: 8px; padding: 10px 12px; width: 100%; }
input:focus-visible, button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.otp { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

button, .btn { font: inherit; cursor: pointer; border: 0; border-radius: 8px; }
.primary { background: var(--accent); color: var(--accent-ink); padding: 11px 18px; font-weight: 600;
           text-align: center; text-decoration: none; display: inline-block; }
.primary:disabled { opacity: .55; cursor: default; }
.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.link.danger { color: var(--danger); }
.msg { margin: 0; font-size: .9rem; color: var(--danger); min-height: 0; }
.msg.ok { color: var(--ok); }
.msg:empty { display: none; }

.drive-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
#meter-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#meter-text { margin-top: 6px; }
.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center;
        color: var(--muted); font-size: .95rem; }
.drop.over { border-color: var(--accent); color: var(--ink); background: var(--panel); }
.queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.queue li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
            display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .9rem; }
.queue .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--accent); }
.queue .err { color: var(--danger); grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; margin-top: 18px; background: var(--panel);
        border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .93rem; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { max-width: 0; width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * + * { margin-left: 14px; }
.empty { text-align: center; color: var(--muted); padding: 26px 0; }
@media (max-width: 560px) { #files th:nth-child(3), #files td:nth-child(3) { display: none; } }

/* administration */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 22px; margin-top: 18px; max-width: 640px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
         border-radius: 8px; padding: 10px 12px; width: 100%; }
label small { font-weight: 400; color: var(--muted); }
.hint { margin: 0; font-size: .86rem; color: var(--muted); }
.pill { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px;
        background: var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 10px 0 12px; font-size: .93rem; }
dt { color: var(--muted); } dd { margin: 0; font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.panel .primary { justify-self: start; }
footer { text-align: center; padding: 0 0 28px; font-size: .82rem; }
footer a { color: var(--muted); }
/* Service version, shown only on the admin page (inside #admin-panel), bottom-right. */
#admin-version { position: fixed; right: 14px; bottom: 10px; font-size: .78rem; color: var(--muted);
  font-variant-numeric: tabular-nums; opacity: .85; pointer-events: none; z-index: 20; }

/* theme switcher */
.bar-right { display: flex; align-items: center; gap: 16px; }
.themes { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); }
.themes button { display: flex; align-items: center; gap: 6px; background: none; color: var(--muted);
                 font-size: .8rem; padding: 4px 10px; border-radius: 99px; }
.themes button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.themes i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(128,128,128,.6); }
.themes [data-set="light"] i { background: #fff; }
.themes [data-set="dark"] i { background: #101614; }
.themes [data-set="gold"] i { background: #d9b24c; }
.langs { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); }
.langs button { background: none; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .02em;
                padding: 4px 10px; border-radius: 99px; }
.langs button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
@media (max-width: 640px) { .themes span { display: none; } .themes button { padding: 6px; } #who-name { display: none; }
                            .bar-right { gap: 8px; } .langs button { padding: 4px 8px; } }

/* phones: file name on its own line, so it is not squeezed by the actions */
@media (max-width: 560px) {
  #files thead { display: none; }
  #files tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
  #files tr:last-child { border-bottom: 0; }
  #files td { padding: 0; border: 0; }
  #files td.name { grid-column: 1 / -1; width: auto; max-width: none; white-space: normal; overflow-wrap: anywhere; }
  #files td.num { text-align: left; color: var(--muted); }
  #files td:nth-child(3) { display: none; }
}
label.check { display: block; font-weight: 400; }
label.check input { width: auto; margin-right: 8px; accent-color: var(--accent); }

/* administration: tabs, users, activity report */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 6px; }
.tabs button { background: none; color: var(--muted); padding: 9px 16px; border-radius: 8px 8px 0 0;
               border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.panel.wide { max-width: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.panel-head input { width: 280px; max-width: 100%; padding: 8px 12px; }
.scroll { overflow-x: auto; }
.panel table { margin-top: 0; border-radius: 8px; }
.panel table + .empty, .panel .scroll + .empty { padding: 16px 0 4px; }
#users td, #audit-events td { vertical-align: top; }
#users .who b { display: block; font-weight: 600; }
#users .who span { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
#users tr.sel td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
#users td.actions button { display: block; margin: 0 0 4px auto; font-size: .88rem; }
.pill.off { background: var(--danger); color: var(--panel); }
.pill.warn { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
             text-decoration: none; font-size: .88rem; margin-right: 12px; }
#audit-events td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
#audit-events td:nth-child(3) { overflow-wrap: anywhere; color: var(--muted); }
#audit-events td:nth-child(4) { font-family: ui-monospace, monospace; font-size: .85rem; white-space: nowrap; }
#audit-events .bad { color: var(--danger); }
#audit-more { margin-top: 12px; }
.panel .hint { margin-top: 12px; }
main:has(#v-admin:not([hidden]) #admin-panel:not([hidden])) { max-width: 1080px; }
#users { min-width: 760px; }            /* narrow screens: scroll sideways inside the panel */
#audit-events { min-width: 640px; }
#users .who span { overflow-wrap: normal; }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
.queue .meta { grid-column: 1 / -1; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.queue .pct { font-variant-numeric: tabular-nums; }

/* monitoring */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile .big { font-size: 2rem; font-weight: 700; font-family: var(--font); color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .lbl { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.tile .sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.mon-rates { display: flex; gap: 24px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.mon-rates b { font-size: 1.15rem; }
.mon-rates .in b { color: var(--accent); } .mon-rates .out b { color: var(--accent2); }
.mon-rates .today { color: var(--muted); margin-left: auto; }
.mon-chart { width: 100%; }
.mon-chart svg { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 18px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; }
.legend .sw-in { background: var(--accent); } .legend .sw-out { background: var(--accent2); }

/* Admin MFA enrolment */
.enroll { border: 1px solid var(--border, #dce1e8); border-radius: 10px; padding: 12px 14px; margin: 4px 0 2px; background: var(--surface-2, #f3f5f8); }
.enroll-title { font-weight: 600; margin: 0 0 4px; }
.enroll-help { font-size: .9rem; color: var(--muted, #5a6577); margin: 0 0 8px; }
.enroll-key { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.enroll-key code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; letter-spacing: .08em; user-select: all; word-break: break-all; }

/* Folders */
.drive-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); padding: 10px 16px; font-weight: 600; }
.btn.ghost:hover { border-color: var(--accent); }
#crumbs { display: flex; align-items: center; gap: 2px; margin: 0 0 18px; font-size: .95rem; color: var(--muted); }
#crumbs .crumb { text-decoration: none; }
#crumbs .crumb-current { color: var(--ink); font-weight: 600; }
.newfolder { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; flex-wrap: wrap; }
.newfolder input { flex: 1 1 220px; margin: 0; }
.newfolder .btn, .newfolder button { padding: 10px 16px; }
.folders { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.folder-chip { display: inline-flex; align-items: center; gap: 10px; background: var(--panel); color: var(--ink);
        border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; text-align: left; }
.folder-chip::before { content: ""; width: 18px; height: 14px; border-radius: 3px 3px 3px 3px;
        background: var(--accent2); box-shadow: inset 0 3px 0 color-mix(in srgb, var(--accent2) 70%, #000 0%); flex: none;
        clip-path: polygon(0 18%, 42% 18%, 52% 0, 100% 0, 100% 100%, 0 100%); }
.folder-chip:hover { border-color: var(--accent); }
.folder-chip .fc-name { white-space: nowrap; }
.folder-chip .fc-count { font-size: .8rem; font-weight: 500; color: var(--muted);
        background: var(--bg); border-radius: 999px; padding: 1px 8px; min-width: 20px; text-align: center; }

/* Branding: header logo + admin upload panel */
.brand-logo { height: 22px; width: auto; max-width: 150px; display: block; object-fit: contain; }
.brand-row { display: flex; align-items: center; gap: 16px; margin: 8px 0; flex-wrap: wrap; }
.brand-preview { display: inline-block; width: 140px; height: 52px; border: 1px solid var(--line);
  border-radius: 8px; background-color: var(--bg); background-size: contain; background-repeat: no-repeat;
  background-position: center; flex: none; }
.brand-preview.empty { background-image: none; }
.brand-file { display: inline-flex; flex-direction: column; gap: 4px; }
.brand-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
