:root {
  --bg: #F2F7FA; --surface: #FFFFFF; --ink: #182C4C; --muted: #4F6280; --line: #D3E0EA;
  --accent: #5CC0E4; --accent-ink: #182C4C; --accent-text: #182C4C; --soft: #DDF1F9;
  --warn: #B42318; --warn-soft: #FBE9E7;
  --t-floor: #D5E8F1; --t-top: #FFFFFF; --t-left: #B3D3E3; --t-right: #8CB6CE; --t-liq: #5CC0E4;
  --radius: 16px;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1B30; --surface: #182C4C; --ink: #EAF4FA; --muted: #A9BDD3; --line: #2B4468;
    --accent: #5CC0E4; --accent-ink: #0F1B30; --accent-text: #8DD6EE; --soft: #1E3A5E;
    --warn: #FF8A80; --warn-soft: #3A2430;
    --t-floor: #20395B; --t-top: #4A6A92; --t-left: #2E4C75; --t-right: #223B5E; --t-liq: #5CC0E4;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Botões e campos ---------- */
.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.btn-block { width: 100%; min-height: 54px; font-size: 17px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input { height: 52px; width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0 16px; font-size: 16px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.form-error { margin: 0; min-height: 0; color: var(--warn); font-size: 14px; font-weight: 500; }
.form-error:empty { display: none; }
.hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--soft); color: var(--accent-text); font-size: 12.5px; font-weight: 500; white-space: nowrap; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: #FFFFFF; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); flex: none; }
.brand-mark img { width: 30px; height: 30px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
.login-head { display: flex; flex-direction: column; gap: 14px; }
.login-head .brand-mark { width: 68px; height: 68px; border-radius: 20px; }
.login-head .brand-mark img { width: 50px; height: 50px; }
.login-head h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -0.02em; }
.login-head p { margin: 0; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 96px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; height: 44px; padding: 0 12px; border: 0; background: none; color: var(--accent-text); font-size: 14px; font-weight: 600; }
@media (min-width: 900px) {
  .login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 40px; max-width: 460px; }
}

/* ---------- Estrutura da lista ---------- */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: calc(14px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-width: 1600px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.search { flex: 1 1 260px; max-width: 560px; height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: 16px; height: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filter-note { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.filter-note button { border: 0; background: none; color: var(--accent-text); font-weight: 600; min-height: 44px; padding: 0 6px; }

.group { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.group-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.group-head span { font-size: 12.5px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

.card-wrap { position: relative; }
.card { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); }
.card:active { transform: scale(.985); }
.thumb { aspect-ratio: 16 / 10; background: var(--soft); overflow: hidden; }
.thumb img, .thumb svg { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-size: 14.5px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.card-status { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.fav { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; border: 0; background: none; padding: 0; display: flex; align-items: center; justify-content: center; }
.fav span { width: 32px; height: 32px; border-radius: 999px; background: var(--surface); color: var(--muted); display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(15, 27, 48, .18); }
.fav[aria-pressed="true"] span { color: var(--accent-text); }

.empty { margin-top: 24px; padding: 32px 20px; border: 1px dashed var(--line); border-radius: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }
.empty strong { color: var(--ink); font-size: 17px; }
.syncnote { margin-top: auto; padding: 12px 14px; border-radius: 14px; background: var(--soft); color: var(--accent-text); display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; }

@media (min-width: 600px) {
  .main { padding-left: 32px; padding-right: 32px; gap: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .card-title { font-size: 15.5px; }
}
@media (min-width: 1024px) {
  .sidebar { display: flex; flex-direction: column; gap: 22px; flex: 0 0 264px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px; }
  .sidebar .brand { padding: 0 8px; }
  .nav { display: flex; flex-direction: column; gap: 4px; }
  .nav-label { padding: 0 12px 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  .nav-item { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: none; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; font-weight: 500; text-align: left; width: 100%; }
  .nav-item > span:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .nav-item:hover { background: var(--soft); }
  .nav-item[aria-current="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  .nav-item small { font-size: 13px; color: inherit; opacity: .75; }
  .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
  .topbar, .chips.mobile-only { display: none; }
  .main { padding: 28px 40px 40px; gap: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
  .group-head h2 { font-size: 20px; }
}

/* ---------- Visualizador ---------- */
.viewer { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0F1B30; color: #EAF4FA; }
.vbar { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; background: #182C4C; border-bottom: 1px solid #2B4468; }
.vbar .icon-btn { background: transparent; border-color: #2B4468; color: #EAF4FA; }
.vbar .icon-btn[aria-pressed="true"] { color: #8DD6EE; }
.vtitle { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vtitle strong { font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtitle span { font-size: 12.5px; color: #A9BDD3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vstage { position: relative; flex: 1; min-height: 0; }
.vstage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0F1B30; }
.vmsg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: #A9BDD3; z-index: 1; pointer-events: none; }
.vmsg strong { color: #EAF4FA; font-size: 17px; }
.vmsg .btn { pointer-events: auto; }
.spinner { width: 36px; height: 36px; border-radius: 999px; border: 3px solid #2B4468; border-top-color: #5CC0E4; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.viewer:fullscreen .vbar { display: none; }

/* ---------- Administração ---------- */
.page { max-width: 760px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; flex: 1; }
.badge-admin { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 600; }
@media (max-width: 480px) {
  .badge-admin { padding: 8px; }
  .badge-admin span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .page-head h1 { font-size: 20px; }
}
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.row-thumb { width: 72px; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: var(--soft); flex: none; }
.row-thumb img, .row-thumb svg { width: 100%; height: 100%; object-fit: cover; }
.row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-info strong { font-size: 14.5px; overflow-wrap: anywhere; }
.row-info span { font-size: 12.5px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions .btn { min-height: 44px; padding: 0 12px; font-size: 13.5px; }
.del { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--warn-soft); color: var(--warn); display: flex; align-items: center; justify-content: center; padding: 0; }
.checkrow { display: flex; align-items: center; gap: 12px; padding: 10px; min-height: 56px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.checkrow input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--accent); }
.checkrow:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.checkrow:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.panel { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0; font-size: 17px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.panel-actions .btn { flex: 1 1 220px; }
.section-title { margin: 8px 0 0; font-size: 17px; }

.drop { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.drop.is-over { border-color: var(--accent); background: var(--soft); }
.drop-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; flex: none; }
.drop-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.drop-info strong { font-size: 14.5px; overflow-wrap: anywhere; }
.drop-info span { font-size: 12.5px; color: var(--muted); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.thumb-box { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.thumb-preview { position: relative; width: 240px; max-width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; background: var(--soft); flex: none; }
.thumb-preview img, .thumb-preview svg { width: 100%; height: 100%; object-fit: cover; }
.thumb-preview iframe { position: absolute; left: 0; top: 0; width: 1280px; height: 800px; border: 0; transform-origin: 0 0; pointer-events: none; }
.thumb-side { flex: 1 1 180px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.thumb-side .btn { min-height: 44px; font-size: 14px; }
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--soft); color: var(--accent-text); font-size: 14px; font-weight: 500; }

/* ---------- Diálogo ---------- */
dialog { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 20px; padding: 22px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(15, 27, 48, .55); }
dialog form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
dialog h2 { margin: 0; font-size: 19px; }
dialog p { margin: 0; color: var(--muted); }
#dlgField { display: flex; flex-direction: column; gap: 6px; }
#dlgField label { font-size: 13px; font-weight: 600; color: var(--muted); }
#dlgInput { height: 52px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); padding: 0 16px; font-size: 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14.5px; font-weight: 500; z-index: 50; box-shadow: 0 6px 24px rgba(15, 27, 48, .25); }

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