:root {
  --bg-deep:      #060f1e;
  --bg-base:      #0b1c3a;
  --bg-sidebar:   #0d2040;
  --bg-card:      #112548;
  --border:       #1e3a6e;
  --border-subtle:#162d55;
  --accent:       #2563eb;
  --accent-light: #3b82f6;
  --accent-glow:  #2563eb33;
  --green:        #10b981;
  --green-bg:     #10b98120;
  --yellow:       #f59e0b;
  --yellow-bg:    #f59e0b18;
  --red:          #ef4444;
  --blue-light:   #60a5fa;
  --text-primary: #e2ecff;
  --text-secondary:#8aabcf;
  --text-muted:   #4a6b8a;
  --font: 'Inter', -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg-deep); color: var(--text-primary);
  height: 100vh; overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; }

/* ── Screens ── */
.screen { height: 100vh; }

/* ── Login ── */
.login-wrap { display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; padding: 24px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon-lg { width: 56px; height: 56px; background: var(--accent); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.logo-icon-lg svg { width: 28px; height: 28px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form { width: 340px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary);
  margin-bottom: 6px; }
.field input { width: 100%; padding: 10px 12px; background: #0a1830; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color 0.15s; }
.field input:focus { border-color: var(--accent-light); }
.login-error { color: var(--red); font-size: 12px; margin-bottom: 10px;
  padding: 8px 12px; background: #ef444418; border-radius: 6px; }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 20px; font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent-light); }
.btn-full { width: 100%; }
.login-footer { margin-top: 20px; text-align: center; }
.login-footer a { font-size: 12px; color: var(--blue-light); text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

/* ── Titlebar ── */
.titlebar { height: 38px; background: var(--bg-deep); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; padding: 0 14px; gap: 10px; flex-shrink: 0;
  -webkit-app-region: drag; }
.titlebar-dots { display: flex; gap: 6px; -webkit-app-region: no-drag; }
.dot { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; }
.dot-close { background: #ff5f56; } .dot-min { background: #febc2e; } .dot-max { background: #28c840; }
.titlebar-title { flex: 1; text-align: center; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.titlebar-user { font-size: 11px; color: var(--text-muted); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── App shell ── */
.app-shell { display: flex; height: calc(100vh - 38px); overflow: hidden; }

/* ── Sidebar ── */
.sidebar { width: 220px; background: var(--bg-sidebar); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 18px 16px 14px; display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 30px; height: 30px; background: var(--accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-icon svg { width: 16px; height: 16px; }
.logo-text { font-size: 14px; font-weight: 700; } .logo-sub { font-size: 10px; color: var(--text-muted); }
.nav-section { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: .08em;
  text-transform: uppercase; padding: 6px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary);
  transition: all .15s; margin-bottom: 2px; }
.nav-item:hover { background: #14306080; color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--blue-light); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-storage { padding: 12px 14px; border-top: 1px solid var(--border-subtle); }
.storage-label { display: flex; justify-content: space-between; font-size: 11px;
  color: var(--text-secondary); margin-bottom: 7px; }
.storage-label strong { color: var(--text-primary); font-weight: 600; }
.storage-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.storage-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue-light));
  border-radius: 2px; transition: width 1s; }
.storage-plan { font-size: 10px; color: var(--text-muted); margin-top: 5px; }

/* ── Main / Pages ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-base); }
.page { flex: 1; display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.topbar { height: 50px; border-bottom: 1px solid var(--border-subtle); display: flex;
  align-items: center; padding: 0 18px; gap: 10px; flex-shrink: 0; }
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 6px; border: 1px solid var(--border); background: transparent;
  color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: all .15s; }
.topbar-btn:hover { border-color: var(--accent-light); color: var(--text-primary); background: var(--accent-glow); }
.content-area { flex: 1; overflow-y: auto; padding: 18px; }

/* ── Stats row ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 14px; }
.stat-icon { width: 30px; height: 30px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; margin-bottom: 10px; }
.stat-icon svg { width: 14px; height: 14px; }
.stat-icon.blue { background: var(--accent-glow); color: var(--blue-light); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-value { font-size: 20px; font-weight: 700; margin-bottom: 3px; }
.stat-label { font-size: 11px; color: var(--text-muted); }

/* ── Quick actions ── */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-btn { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px;
  padding: 16px 20px; cursor: pointer; text-align: center; transition: all .15s; min-width: 110px; }
.quick-btn:hover { border-color: var(--accent-light); background: #14306080; }
.quick-icon { font-size: 24px; margin-bottom: 8px; }
.quick-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 600; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12px;
  color: var(--text-secondary); margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb span { cursor: pointer; } .breadcrumb span:hover { color: var(--blue-light); }

/* ── Image grid ── */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.image-thumb { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px;
  overflow: hidden; transition: border-color .15s; }
.image-thumb:hover { border-color: var(--accent-light); }
.image-thumb-inner { aspect-ratio: 1; overflow: hidden; display: flex; position: relative;
  align-items: center; justify-content: center; background: var(--bg-deep); cursor: pointer; }
.image-thumb-inner img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.image-thumb-name { padding: 6px 8px; font-size: 10px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── File list ── */
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px;
  cursor: pointer; transition: all .15s; }
.file-row:hover { border-color: var(--border); background: #14306080; }
.file-icon-sm { font-size: 20px; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-path { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.file-date { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ── Lightbox ── */
#lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); }
.lb-content { position: relative; max-width: 90vw; max-height: 90vh; background: var(--bg-card);
  border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.lb-header { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
.lb-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.lb-close { background: none; border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.lb-close:hover { color: var(--text-primary); background: var(--border); }
.lb-img { display: block; max-width: 80vw; max-height: calc(90vh - 50px); object-fit: contain; }

/* ── Settings ── */
.settings-section { background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 18px; max-width: 480px; }
.settings-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: 14px; }
.info-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; }
.info-row-label { color: var(--text-secondary); } .info-row-value { color: var(--text-primary); font-weight: 500; }

/* ── Misc ── */
.loading, .error-msg, .empty-state { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }
.error-msg { color: var(--red); }
::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Upload ── */
.topbar-btn-primary { background: var(--blue) !important; color: #fff !important; }
.topbar-btn-primary:hover { opacity: .9; }
.drop-zone-active { outline: 2px dashed var(--blue); outline-offset: -4px; }
.drop-overlay { position: absolute; inset: 0; background: rgba(59,130,246,.12); z-index: 50;
  display: flex; align-items: center; justify-content: center; pointer-events: none; border-radius: 8px; }
.drop-msg { text-align: center; color: var(--blue); font-weight: 600; font-size: 18px; }
.drop-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 24px; padding-bottom: 8px; }
#upload-toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; width: 300px; }
.upload-toast { background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.ut-name { font-weight: 500; color: var(--text-primary); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ut-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; margin-bottom: 6px; }
.ut-bar { background: var(--accent-light); height: 6px; border-radius: 4px; transition: width .3s ease; }
.ut-meta { display: flex; justify-content: space-between; align-items: center; }
.ut-status { color: var(--text-secondary); font-size: 11px; }
.ut-eta { color: var(--text-muted); font-size: 11px; }

/* ── Delete button ── */
.btn-delete { background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px 6px; border-radius: 4px; opacity: 0; transition: opacity .15s, color .15s; flex-shrink: 0; }
.file-row:hover .btn-delete { opacity: 1; }
.btn-delete:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── Topbar actions ── */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-upload-main { display: inline-flex; align-items: center; gap: 5px; background: var(--blue);
  color: #fff; border: none; border-radius: 7px; padding: 7px 14px; font-size: 13px;
  font-weight: 500; cursor: pointer; font-family: inherit; transition: opacity .15s; }
.btn-upload-main:hover { opacity: .88; }

/* ── Image grid ── */
.image-thumb-footer { display: flex; align-items: center; justify-content: space-between;
  padding: 5px 4px 2px; gap: 4px; }
.image-thumb-name { font-size: 11px; color: var(--text-secondary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1; }
.image-thumb-actions { display: flex; gap: 2px; flex-shrink: 0; }
.img-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0); display: flex;
  align-items: center; justify-content: center; transition: background .2s; border-radius: 6px; }
.image-thumb-inner:hover .img-overlay { background: rgba(0,0,0,.35); }
.img-overlay-icon { font-size: 22px; opacity: 0; transition: opacity .2s; }
.image-thumb-inner:hover .img-overlay-icon { opacity: 1; }
.img-action-btn { background: rgba(255,255,255,.1); border: none; border-radius: 4px;
  color: var(--text-secondary); cursor: pointer; padding: 3px 5px; transition: background .15s, color .15s; }
.img-action-btn:hover { background: var(--blue); color: #fff; }
.img-action-del:hover { background: var(--red) !important; }

/* ── File row actions ── */
.file-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.file-size-inline { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.btn-file-action { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-hover, #2a2a3e);
  border: 1px solid var(--border-subtle); border-radius: 5px; color: var(--text-secondary);
  cursor: pointer; font-size: 12px; padding: 4px 9px; transition: all .15s; }
.btn-file-action:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-file-del { padding: 4px 7px; }
.btn-file-del:hover { background: var(--red) !important; border-color: var(--red) !important; }

/* ── Lightbox ── */
.lb-header { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); gap: 12px; }
.lb-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lb-btn { display: inline-flex; align-items: center; gap: 5px; background: var(--border);
  border: none; border-radius: 5px; color: var(--text-secondary); cursor: pointer;
  font-size: 12px; padding: 5px 10px; transition: all .15s; }
.lb-btn:hover { background: var(--blue); color: #fff; }
.lb-btn-del:hover { background: var(--red) !important; }
.lb-img-wrap { display: flex; align-items: center; justify-content: center;
  min-height: 300px; max-height: calc(90vh - 110px); position: relative; }
.lb-img-center { display: flex; align-items: center; justify-content: center;
  flex: 1; position: relative; min-height: 200px; }
.lb-img { display: block; max-width: 78vw; max-height: calc(90vh - 120px);
  object-fit: contain; transition: opacity .3s; }
.lb-spinner { position: absolute; color: var(--text-muted); font-size: 13px; }
.lb-nav { position: relative; z-index: 2; background: rgba(255,255,255,.08);
  border: none; border-radius: 6px; color: #fff; cursor: pointer;
  font-size: 32px; padding: 8px 14px; transition: background .15s; flex-shrink: 0; }
.lb-nav:hover { background: rgba(255,255,255,.18); }
.lb-footer { text-align: center; font-size: 12px; color: var(--text-muted);
  padding: 8px 14px; border-top: 1px solid var(--border-subtle); }

/* ── Document preview modal ── */
#doc-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.doc-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); }
.doc-content { position: relative; width: 92vw; height: 90vh; background: var(--bg-card);
  border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.doc-header { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; gap: 12px; }
.doc-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500;
  color: var(--text-primary); overflow: hidden; }
.doc-title-icon { font-size: 18px; flex-shrink: 0; }
.doc-header-btns { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.doc-body { flex: 1; overflow: hidden; display: flex; }
.doc-iframe { width: 100%; height: 100%; border: none; background: #fff; }
.doc-video { width: 100%; height: 100%; background: #000; object-fit: contain; }
.doc-text-content { width: 100%; height: 100%; overflow: auto; padding: 20px 24px;
  font-family: 'Consolas', monospace; font-size: 13px; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-all; line-height: 1.6; }
.doc-loading { display: flex; align-items: center; justify-content: center;
  width: 100%; color: var(--text-muted); font-size: 13px; }
.doc-unsupported { display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 100%; color: var(--text-muted); font-size: 13px; text-align: center; }
.btn-file-preview { color: var(--text-secondary); }
.btn-file-preview:hover { background: #6366f1 !important; border-color: #6366f1 !important; color: #fff !important; }

/* ── Activity log ── */
.act-list { display: flex; flex-direction: column; gap: 4px; max-width: 700px; }
.act-row { display: flex; align-items: center; gap: 12px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 14px; }
.act-icon { width: 32px; height: 32px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.act-meta { flex: 1; min-width: 0; }
.act-name { font-size: 13px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.act-time { font-size: 11px; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.act-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; }
.act-err { background: #ef444422; color: var(--red); }

/* ── Video convert ── */
.doc-convert-msg { display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 100%; color: var(--text-secondary); font-size: 14px; text-align: center; }

/* ── Folder grid ── */
.folder-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.folder-item { display: flex; align-items: center; gap: 8px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: 8px; padding: 8px 14px;
  cursor: pointer; font-size: 13px; color: var(--text-primary); transition: all .15s; }
.folder-item:hover { border-color: #f59e0b55; background: #f59e0b11; }
.folder-name { font-weight: 500; }

/* ── Conversion spinner ── */
.conv-spinner { width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--blue-light); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.conv-progress-wrap { width: 260px; margin: 16px auto 8px; }
.conv-progress-track { background: var(--border); border-radius: 6px; height: 8px; overflow: hidden; }
.conv-progress-bar { height: 8px; border-radius: 6px; background: var(--accent-light);
  transition: width .6s ease; width: 0%; }
.conv-progress-meta { display: flex; justify-content: space-between;
  margin-top: 6px; font-size: 11px; color: var(--text-muted); }
