/* Almasa Media Gallery — web dashboard (from WEB.dc.html design) */
:root {
  --primary: #2e3192;
  --primary-dark: #24276f;
  --primary-tint: #ecedfb;
  --primary-border: #d5d7f3;
  --bg: #f6f6fb;
  --surface: #fff;
  --border: #e7e8f4;
  --chip-bg: #eef0f6;
  --chip-border: #e2e4f0;
  --text: #191a2b;
  --text-mid: #4a4d66;
  --text-muted: #6b6e86;
  --text-faint: #8a8db0;
  --text-ghost: #9a9dc0;
  --success: #159b74;
  --success-bg: #f1faf5;
  --success-border: #d6ece0;
  --danger: #c0392b;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  color: var(--text);
}
input, select, button { font-family: inherit; }
button { border: none; background: none; cursor: pointer; padding: 0; color: inherit; }
[hidden] { display: none !important; }
.mono { font: 700 10px var(--mono); letter-spacing: 1.2px; color: var(--text-muted); text-transform: uppercase; }
@keyframes pulse { 0% { opacity: .5 } 50% { opacity: 1 } 100% { opacity: .5 } }

/* ─── Login ─── */
#login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 400px; max-width: 100%; display: flex; flex-direction: column; }
.login-card .logo { height: 24px; align-self: flex-start; margin-bottom: 26px; }
.login-title { font-size: 24px; font-weight: 800; letter-spacing: -.24px; }
.login-sub { font-size: 13px; font-weight: 600; line-height: 1.5; color: var(--text-muted); margin-top: 8px; }
.login-box {
  margin-top: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  overflow: hidden; box-shadow: 0 10px 24px rgba(19,20,59,.06);
}
.login-search { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; }
.login-search input { flex: 1; border: none; outline: none; background: none; font-size: 15px; font-weight: 700; color: var(--text); }
.login-search input::placeholder { color: var(--text-ghost); }
#login-results { border-top: 1px solid #eef0f6; padding: 6px; }
#login-results:empty { display: none; border: none; }
.profile-row {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer;
}
.profile-row.selected { border-color: var(--primary-border); background: #f2f3fc; }
.profile-row .avatar { width: 34px; height: 34px; border-radius: 50%; background: #e3e4f5; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
.profile-row.selected .avatar { background: var(--primary); color: #fff; }
.profile-row .name { flex: 1; font-size: 13px; font-weight: 800; }
.profile-row .check { width: 19px; height: 19px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.login-empty { padding: 14px; font-size: 12px; font-weight: 600; line-height: 1.5; color: var(--text-muted); }
.login-hint { font-size: 11px; font-weight: 600; color: var(--text-ghost); margin-top: 12px; padding: 0 2px; }
.btn-primary {
  margin-top: 22px; min-height: 54px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: var(--primary); border: 1px solid var(--primary-dark); color: #fff; font-size: 16px; font-weight: 800; width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #e3e4f5; border-color: var(--primary-border); color: var(--text-ghost); cursor: default; }
.otp-boxes { position: relative; display: flex; gap: 9px; margin-top: 26px; }
.otp-box {
  flex: 1; height: 58px; border-radius: 13px; border: 2px solid var(--chip-border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800;
}
.otp-box.filled { border-color: #c5c7ec; }
.otp-box.active { border-color: var(--primary); box-shadow: 0 0 6px rgba(46,49,146,.25); }
.otp-caret { width: 2px; height: 24px; border-radius: 2px; background: var(--primary); animation: pulse 1.1s infinite; }
#otp-input { position: absolute; inset: 0; opacity: .011; color: transparent; border: none; outline: none; background: none; font-size: 24px; letter-spacing: 40px; }
.otp-resend-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; min-height: 20px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.otp-resend-row .link { font-weight: 800; color: var(--primary); cursor: pointer; }
.otp-resend-row .wait { font-weight: 800; color: #b6b9d4; }
.login-error { margin-top: 12px; font-size: 12px; font-weight: 700; color: var(--danger); text-align: center; }
.login-back {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--primary-border);
  border-radius: 10px; background: var(--surface); font-size: 16px; font-weight: 800; color: var(--primary); margin-bottom: 22px; cursor: pointer;
}
.otp-glyph { width: 60px; height: 60px; border-radius: 18px; background: var(--primary-tint); display: flex; align-items: center; justify-content: center; margin-bottom: 22px; font: 800 13px var(--mono); letter-spacing: 1px; color: var(--primary); }
.sso-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 11px; font-weight: 600; color: var(--text-ghost); }
.sso-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary-tint); border: 1px solid var(--primary-border); color: var(--primary); font-size: 7px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* ─── Header ─── */
header {
  display: flex; align-items: center; gap: 18px; padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
header .logo { height: 22px; }
header .app-label { font: 700 10px var(--mono); letter-spacing: 1.4px; color: var(--text-muted); text-transform: uppercase; border-left: 1px solid var(--border); padding-left: 16px; }
.search-box {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px; background: #f8f8fc; margin-left: 12px;
}
.search-box:focus-within { border-color: var(--primary); }
.search-box input { flex: 1; border: none; outline: none; background: none; font-size: 13px; font-weight: 600; color: var(--text); }
.search-box input::placeholder { color: var(--text-faint); }
.search-clear { color: var(--text-faint); font-size: 12px; font-weight: 800; cursor: pointer; }
.spacer { flex: 1; }
.btn-filters {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text-mid); font-size: 12.5px; font-weight: 800;
}
.btn-filters:hover { filter: brightness(1.03); }
.btn-filters.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-filters .count { background: rgba(255,255,255,.25); border-radius: 5px; padding: 1px 6px; font-size: 10.5px; }
.btn-upload { padding: 8px 14px; border: 1px solid var(--primary-border); border-radius: 10px; background: var(--primary-tint); color: var(--primary); font-size: 12.5px; font-weight: 800; }
.btn-upload:hover { background: #e2e3f8; }
.header-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; cursor: pointer; }

/* ─── Toolbar ─── */
main { flex: 1; padding: 20px 24px 40px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--chip-bg); border: 1px solid var(--chip-border); border-radius: 10px; padding: 3px; }
.tabs span { cursor: pointer; padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.tabs span.on { background: var(--surface); box-shadow: 0 1px 4px rgba(19,20,59,.1); font-weight: 800; color: var(--primary); }
.result-count { font-size: 12px; font-weight: 600; color: var(--text-faint); margin-left: 6px; }
.chip {
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--primary-border);
  border-radius: 8px; background: var(--primary-tint); color: var(--primary); font-size: 11.5px; font-weight: 800;
}
.chip:hover { background: #e2e3f8; }
.chip .x { opacity: .55; }
.clear-all { cursor: pointer; font-size: 11.5px; font-weight: 800; color: var(--primary); }
.sort-btn { cursor: pointer; font: 700 10px var(--mono); letter-spacing: 1px; color: var(--text-faint); }
.sort-btn:hover { color: var(--primary); }

/* ─── Grid ─── */
#grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px) { #grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { #grid { grid-template-columns: repeat(2, 1fr); } }
.card {
  cursor: pointer; position: relative; height: 230px; border-radius: 14px; overflow: hidden; background: #d8daef;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 10px 30px rgba(19,20,59,.18); transform: translateY(-2px); }
.card img.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19,20,59,0) 35%, rgba(19,20,59,.85)); }
.card .play-bubble { position: absolute; top: 10px; left: 10px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.94); display: flex; align-items: center; justify-content: center; }
.play-tri { width: 0; height: 0; border-left: 10px solid var(--primary); border-top: 6px solid transparent; border-bottom: 6px solid transparent; margin-left: 2px; }
.card .dur { position: absolute; top: 14px; right: 12px; padding: 2px 7px; border-radius: 6px; background: rgba(19,20,59,.7); color: #fff; font-size: 10px; font-weight: 700; }
.card .letter-badge { position: absolute; top: 12px; left: 12px; padding: 3px 9px; border-radius: 7px; background: rgba(255,255,255,.92); color: var(--primary); font-size: 9.5px; font-weight: 800; }
.card .meta { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; color: #fff; }
.card .meta .name { font-size: 13.5px; font-weight: 800; line-height: 1.25; }
.card .badges { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.mini-tag { padding: 3px 8px; border-radius: 7px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.28); font-size: 10px; font-weight: 800; }
.card .sub { font-size: 10.5px; font-weight: 700; color: #c9cbee; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 80px 0; color: var(--text-faint); }
.empty-state .title { font-size: 14px; font-weight: 800; color: var(--text-mid); }
.empty-state .sub { font-size: 12px; font-weight: 600; }
.btn-reset { cursor: pointer; padding: 9px 18px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 800; }

/* ─── Letters split view ─── */
.letters-wrap { display: flex; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); min-height: 560px; }
.letters-list { width: 390px; flex: none; border-right: 1px solid var(--border); background: #fbfbfe; padding: 18px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.letter-row { cursor: pointer; display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.letter-row:hover { border-color: #c3c5f0; }
.letter-row.selected { border-color: var(--primary); background: var(--primary-tint); }
.letter-icon { width: 40px; height: 52px; flex: none; border-radius: 6px; background: #fff; border: 1px solid #dfe1ef; box-shadow: 0 2px 6px rgba(19,20,59,.08); display: flex; flex-direction: column; gap: 3px; padding: 7px 6px; }
.letter-icon i { display: block; height: 2px; background: #dfe1ef; border-radius: 2px; }
.letter-icon i:first-child { height: 3px; width: 60%; background: var(--primary); }
.letter-icon i:last-child { width: 70%; }
.letter-row .client { font-size: 13px; font-weight: 800; }
.letter-row .plant { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.letter-row .sector { padding: 2px 7px; border: 1px solid var(--primary-border); border-radius: 6px; background: var(--primary-tint); color: var(--primary); font-size: 9.5px; font-weight: 800; }
.letter-row .date { font: 700 9px var(--mono); color: var(--text-faint); }
.letter-preview { flex: 1; background: #eceef5; padding: 24px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.letter-preview .bar { display: flex; align-items: center; gap: 10px; }
.letter-preview .bar .title { font-size: 15px; font-weight: 800; }
.btn-ghost { cursor: pointer; padding: 7px 14px; border: 1px solid var(--primary-border); border-radius: 9px; background: var(--surface); color: var(--primary); font-size: 12px; font-weight: 800; }
.btn-ghost:hover { background: var(--primary-tint); }
.letter-paper {
  background: var(--surface); border-radius: 6px; box-shadow: 0 10px 40px rgba(19,20,59,.14);
  max-width: 600px; align-self: center; width: 100%; padding: 44px 52px; display: flex; flex-direction: column; gap: 18px;
}
.letter-paper .head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 2px solid var(--primary); }
.letter-paper .org-avatar { width: 38px; height: 38px; border-radius: 8px; background: var(--primary-tint); border: 1px solid var(--primary-border); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--primary); }
.letter-paper .org { font-size: 14px; font-weight: 800; }
.letter-paper .ref { font: 700 9px var(--mono); color: var(--text-faint); letter-spacing: .5px; }
.letter-paper .subject { font-size: 12.5px; font-weight: 700; color: var(--text-mid); }
.letter-paper img.page { width: 100%; border-radius: 6px; }
.letter-paper .signer-line { width: 110px; height: 26px; border-bottom: 1.5px solid #c3c5de; }
.letter-paper .signer { font-size: 11px; font-weight: 800; }
.letter-paper .role { font-size: 10px; font-weight: 700; color: var(--text-faint); }

/* ─── Filter drawer ─── */
.overlay { position: fixed; inset: 0; background: rgba(19,20,59,.32); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 320px; background: var(--surface);
  box-shadow: -18px 0 50px rgba(19,20,59,.2); padding: 22px; display: flex; flex-direction: column; gap: 18px; z-index: 31; overflow: auto;
}
.drawer h2 { margin: 0; font-size: 16px; font-weight: 800; }
.drawer .close { cursor: pointer; font-size: 13px; color: var(--text-faint); font-weight: 700; padding: 4px 8px; }
.fgroup { display: flex; flex-direction: column; gap: 8px; }
.fopts { display: flex; flex-wrap: wrap; gap: 6px; }
.fopt { cursor: pointer; padding: 6px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-muted); font-size: 12px; font-weight: 700; }
.fopt:hover { border-color: var(--primary); }
.fopt.on { border-color: var(--primary-border); background: var(--primary-tint); color: var(--primary); font-weight: 800; }
.drawer-actions { display: flex; gap: 10px; margin-top: auto; }
.drawer-actions .reset { cursor: pointer; flex: 1; text-align: center; padding: 13px 0; border: 1px solid var(--border); border-radius: 14px; font-size: 13px; font-weight: 800; color: var(--text-muted); }
.drawer-actions .reset:hover { background: var(--bg); }
.drawer-actions .show { cursor: pointer; flex: 1; text-align: center; padding: 13px 0; border-radius: 14px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 800; }
.drawer-actions .show:hover { background: var(--primary-dark); }

/* ─── Detail modal ─── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(13,14,40,.7); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 30px; }
.detail-modal { width: 860px; max-width: 100%; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.player-area { position: relative; height: 420px; background: #1e2050; display: flex; align-items: center; justify-content: center; }
.player-area video, .player-area img.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #101128; }
.player-overlay-play { position: relative; z-index: 2; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.95); box-shadow: 0 8px 24px rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.player-overlay-play .tri { width: 0; height: 0; border-left: 18px solid var(--primary); border-top: 11px solid transparent; border-bottom: 11px solid transparent; margin-left: 5px; }
.player-bar { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; align-items: center; gap: 10px; z-index: 2; }
.player-bar .t { font: 700 10px var(--mono); color: #fff; }
.player-bar .t.dim { color: rgba(255,255,255,.7); }
.seek { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); cursor: pointer; }
.seek .fill { height: 4px; border-radius: 2px; background: #fff; width: 0; }
.stream-badge { padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.45); color: #fff; font: 700 9px var(--mono); }
.player-btn { cursor: pointer; position: absolute; top: 12px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 800; z-index: 3; }
.player-btn.close { right: 12px; }
.player-btn.fs { right: 54px; font-size: 14px; }
.detail-meta { padding: 20px 24px; display: flex; flex-direction: column; gap: 13px; }
.detail-meta h1 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.3; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-muted); font-size: 10.5px; font-weight: 800; }
.tag.hl { border-color: var(--primary-border); background: var(--primary-tint); color: var(--primary); }
.tag.dim { background: var(--chip-bg); }
.detail-desc { font-size: 13px; font-weight: 600; color: var(--text-muted); line-height: 1.55; }
.action-row { display: flex; gap: 10px; align-items: center; }
.btn-play { cursor: pointer; padding: 12px 26px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 13.5px; font-weight: 800; }
.btn-play:hover { background: var(--primary-dark); }
.btn-dl { cursor: pointer; padding: 12px 20px; border-radius: 14px; background: #1c1e3f; color: #dfe0ff; font-size: 13.5px; font-weight: 800; border: 1px solid rgba(90,94,219,.4); }
.btn-dl.done { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.related-label { font: 700 9.5px var(--mono); letter-spacing: 1.2px; color: var(--text-muted); margin-top: 4px; }
.related-row { display: flex; gap: 12px; padding-bottom: 6px; }
.related-item { cursor: pointer; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.related-item:hover { opacity: .8; }
.related-thumb { position: relative; height: 88px; border-radius: 10px; background: #e7e8f6; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.related-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.related-thumb .bub { position: relative; z-index: 2; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.94); display: flex; align-items: center; justify-content: center; }
.related-thumb .bub .tri { width: 0; height: 0; border-left: 8px solid var(--primary); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; margin-left: 2px; }
.related-item .name { font-size: 11px; font-weight: 800; line-height: 1.25; }
.related-item .dur { font: 700 9px var(--mono); color: var(--text-faint); }

/* fullscreen mode */
.modal-backdrop.fs { padding: 0; background: rgba(0,0,0,.96); }
.modal-backdrop.fs .detail-modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; background: #000; }
.modal-backdrop.fs .player-area { height: 100%; }
.modal-backdrop.fs .detail-meta, .modal-backdrop.fs .related-label, .modal-backdrop.fs .related-row { display: none; }
.fs-title { position: absolute; left: 16px; top: 14px; display: none; align-items: center; gap: 10px; color: #fff; z-index: 3; }
.modal-backdrop.fs .fs-title { display: flex; }
.fs-title .nm { font-size: 14px; font-weight: 800; }
.fs-title .lang { padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); font: 700 9px var(--mono); }

/* ─── Upload modal ─── */
.upload-backdrop { position: fixed; inset: 0; background: rgba(13,14,40,.55); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 30px; }
.upload-modal { width: 640px; max-width: 100%; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 80px rgba(19,20,59,.35); padding: 26px 28px; display: flex; flex-direction: column; gap: 18px; }
.upload-modal h2 { margin: 0; font-size: 17px; font-weight: 800; }
.dropzone { border: 1.5px dashed #c3c5de; border-radius: 14px; background: #fbfbfe; padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.dropzone.drag { border-color: var(--primary); background: var(--primary-tint); }
.dropzone .up-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-tint); border: 1px solid var(--primary-border); display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 18px; font-weight: 800; }
.dropzone .dz-title { font-size: 13.5px; font-weight: 800; }
.dropzone .dz-sub { font-size: 11.5px; font-weight: 600; color: var(--text-faint); }
.dropzone .dz-sub b { color: var(--primary); font-weight: 800; }
.upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font: 700 9.5px var(--mono); letter-spacing: 1px; color: var(--text-muted); }
.field input, .field select { border: 1px solid #dfe1ef; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 700; outline: none; background: var(--surface); color: var(--text); }
.field input:focus, .field select:focus { border-color: var(--primary); }
.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.upload-progress .track { height: 6px; border-radius: 3px; background: var(--chip-bg); }
.upload-progress .fill { height: 6px; border-radius: 3px; background: var(--primary); width: 0; transition: width .3s; }
.upload-progress .label { font: 700 9.5px var(--mono); color: var(--text-faint); }
.upload-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }
.btn-cancel { cursor: pointer; padding: 12px 22px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; font-weight: 800; color: var(--text-muted); }
.btn-publish { cursor: pointer; padding: 12px 22px; border-radius: 12px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 800; }
.btn-publish:hover { background: var(--primary-dark); }
.btn-publish:disabled { background: #e3e4f5; color: var(--text-ghost); cursor: default; }

/* toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #191a2b; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 13px; font-weight: 700; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.3); }

/* ═══════════════════════════════════════════════════════════════════════════
   Dashboard shell (sidebar + topbar) — shared Almasa layout
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --side-bg: var(--surface);
  --side-border: var(--border);
  --topbar-bg: rgba(255,255,255,.9);
  --soft: #f8f8fc;
  --soft-2: #f2f3fc;
}
#app-view { min-height: 100vh; }
.shell { display: grid; grid-template-columns: 264px minmax(0,1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.shell.sidebar-collapsed { grid-template-columns: 78px minmax(0,1fr); }

/* Sidebar */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; border-right: 1px solid var(--side-border); background: var(--side-bg); }
.brand-block { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; min-width: 0; }
.brand-text { min-width: 0; }
.brand-text .kicker { margin: 0 0 3px; font: 800 11px var(--mono); letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-faint); }
.brand-text h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.2px; color: var(--text); line-height: 1.1; white-space: nowrap; }
.side-toggle { flex: none; width: 32px; height: 32px; margin-left: auto; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--soft); color: var(--text-muted); }
.side-toggle:hover { background: var(--primary-tint); color: var(--primary); }
.side-toggle .ic-expand { display: none; }
.sidebar-collapsed .side-toggle .ic-collapse { display: none; }
.sidebar-collapsed .side-toggle .ic-expand { display: block; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 700; text-align: left; }
.nav-item svg { flex: none; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--soft-2); color: var(--primary); }
.nav-item.on { background: var(--primary-tint); border-color: var(--primary-border); color: var(--primary); }

.session-card { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 11px; border: 1px solid var(--side-border); border-radius: 11px; background: var(--soft); }
.sess-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.sess-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sess-meta strong { font-size: 13px; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-meta span { margin-top: 1px; font-size: 11.5px; font-weight: 600; color: var(--text-faint); }
.sess-out { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--text-faint); }
.sess-out:hover { background: var(--primary-tint); color: var(--primary); }

/* Collapsed sidebar */
.sidebar-collapsed .side { align-items: center; padding-inline: 10px; }
.sidebar-collapsed .brand-block { flex-direction: column; gap: 10px; padding: 0 0 16px; width: 100%; }
.sidebar-collapsed .brand-text, .sidebar-collapsed .nav-item span, .sidebar-collapsed .sess-meta, .sidebar-collapsed .sess-out { display: none; }
.sidebar-collapsed .side-toggle { margin-left: 0; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar-collapsed .session-card { justify-content: center; padding: 10px 0; }

/* Main + topbar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--topbar-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-btn { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.tb-btn:hover, .tb-btn.on { background: var(--primary-tint); border-color: var(--primary-border); color: var(--primary); }
.tb-logo-wrap { display: inline-flex; align-items: center; height: 22px; }
.tb-logo { height: 22px; }
#tb-title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.2px; color: var(--text); white-space: nowrap; }
.lang-switch, .theme-switch { display: inline-flex; flex: none; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--soft); }
.lang-switch button { min-height: 28px; padding: 0 10px; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 800; }
.theme-switch button { width: 30px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: transparent; color: var(--text-muted); }
.lang-switch button.on, .theme-switch button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(19,20,59,.1); }
.lang-switch button:hover, .theme-switch button:hover { color: var(--primary); }
.topbar .search-box { flex: 0 1 320px; max-width: 320px; min-width: 180px; margin-left: 0; color: var(--text-faint); }
.topbar .search-box input { color: var(--text); }

/* Page area */
.page-motion { padding: 20px 24px 44px; }
.page-view[hidden] { display: none !important; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-view { animation: pageIn .22s ease; }

/* ═══════════ Access Management ═══════════ */
.page-stack { display: flex; flex-direction: column; gap: 18px; }
.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 22px; box-shadow: 0 6px 20px rgba(19,20,59,.04); }
.panel-heading { margin-bottom: 18px; }
.panel-heading .page-title { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.3px; color: var(--text); }
.panel-heading h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--text); }
.panel-heading span { display: block; margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.access-form { display: grid; grid-template-columns: minmax(0,1fr) 180px auto; gap: 14px; align-items: end; }
.access-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; position: relative; }
.access-field > label { font: 800 10.5px var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }
.access-field input, .access-field select { min-height: 46px; padding: 0 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--soft); font-size: 14px; font-weight: 600; color: var(--text); outline: none; }
.access-field input:focus, .access-field select:focus { border-color: var(--primary); background: var(--surface); }
.access-field select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b6e86' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
.access-add-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 11px; background: var(--primary); border: 1px solid var(--primary-dark); color: #fff; font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.access-add-btn:hover { background: var(--primary-dark); }
.access-add-btn:disabled { background: #e3e4f5; border-color: var(--primary-border); color: var(--text-ghost); cursor: default; }

.dir-dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 14px 34px rgba(19,20,59,.16); padding: 6px; }
.dir-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border-radius: 9px; background: transparent; text-align: left; }
.dir-row:hover { background: var(--soft-2); }
.dir-row .av { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; font-size: 11px; font-weight: 800; object-fit: cover; overflow: hidden; }
.dir-row .txt { min-width: 0; display: flex; flex-direction: column; }
.dir-row .txt strong { font-size: 13px; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dir-row .txt small { font-size: 11px; font-weight: 600; color: var(--text-faint); }
.dir-status { padding: 12px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.access-msg { margin-top: 14px; font-size: 12.5px; font-weight: 700; }
.access-msg.ok { color: var(--success); }
.access-msg.err { color: var(--danger); }

.table-wrap { margin-top: 18px; overflow-x: auto; }
table.access-table { width: 100%; border-collapse: collapse; }
table.access-table th { text-align: left; padding: 0 14px 10px; font: 800 10px var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.access-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); vertical-align: middle; }
table.access-table tr:last-child td { border-bottom: none; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.user-cell .av { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; font-size: 11px; font-weight: 800; overflow: hidden; }
.user-cell .av img { width: 100%; height: 100%; object-fit: cover; }
.mono-id { font: 600 12px var(--mono); color: var(--text-muted); }

.role-badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.role-badge.admin { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.role-badge.view { background: var(--chip-bg); color: var(--text-mid); border: 1px solid var(--chip-border); }
.role-select { min-height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--text); }

.row-actions { display: inline-flex; align-items: center; gap: 7px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-muted); }
.icon-btn:hover { border-color: var(--primary-border); background: var(--primary-tint); color: var(--primary); }
.icon-btn.danger:hover { border-color: #ecc7c3; background: #fdeeec; color: var(--danger); }
.confirm-btn { min-height: 32px; padding: 0 12px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 800; }
.locked-note { display: inline-flex; align-items: center; gap: 5px; font: 700 10px var(--mono); letter-spacing: .8px; text-transform: uppercase; color: var(--text-ghost); }
.access-empty { padding: 26px 14px; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--text-faint); }

/* ═══════════ Dark theme ═══════════ */
html[data-theme="dark"] {
  --primary: #7a7ee6;
  --primary-dark: #6367d6;
  --primary-tint: #24263f;
  --primary-border: #34375c;
  --bg: #101120;
  --surface: #181a2c;
  --border: #262844;
  --chip-bg: #21233a;
  --chip-border: #2e3150;
  --text: #ecedfb;
  --text-mid: #c2c4dd;
  --text-muted: #9a9dc0;
  --text-faint: #7b7ea3;
  --text-ghost: #63668a;
  --success: #35c896;
  --success-bg: #10241d;
  --success-border: #1f4739;
  --danger: #ef6a5c;
  --side-bg: #141626;
  --side-border: #24263f;
  --topbar-bg: rgba(20,22,38,.85);
  --soft: #1e2035;
  --soft-2: #202243;
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .card { background: #22243a; }
html[data-theme="dark"] .login-box, html[data-theme="dark"] .otp-box { background: var(--surface); }
html[data-theme="dark"] #login-results { border-top-color: var(--border); }
html[data-theme="dark"] .profile-row.selected { background: var(--soft-2); }
html[data-theme="dark"] .search-box { background: var(--soft); }
html[data-theme="dark"] .panel { box-shadow: 0 6px 20px rgba(0,0,0,.3); }
html[data-theme="dark"] .icon-btn.danger:hover { background: #2a1a1a; border-color: #5a2f2b; }

/* ═══════════ Responsive ═══════════ */
@media (max-width: 860px) {
  .shell, .shell.sidebar-collapsed { grid-template-columns: 78px minmax(0,1fr); }
  .side { align-items: center; padding-inline: 10px; }
  .brand-text, .nav-item span, .sess-meta, .sess-out { display: none; }
  .brand-block { flex-direction: column; gap: 10px; padding: 0 0 16px; }
  .nav-item { justify-content: center; padding: 0; }
  .side-toggle { display: none; }
  .topbar { flex-wrap: wrap; }
  .topbar .search-box { flex: 1 1 100%; max-width: none; order: 3; }
  .access-form { grid-template-columns: 1fr; }
}
