:root {
  /* Гэгээлэг, цайвар загвар — системийн харанхуй горимоос үл хамаарна */
  --bg: #f7fbff;
  --bg-glow: radial-gradient(1200px 500px at 10% -10%, #e3f1ff 0%, transparent 60%),
             radial-gradient(900px 400px at 100% 0%, #e6fbf2 0%, transparent 55%);
  --surface: #ffffff;
  --text: #1b2a3a;
  --muted: #6b7c8f;
  --border: #e3ebf3;
  --accent: #2b7de9;
  --accent-hover: #1f6fd6;
  --accent-soft: #eaf3ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgb(30 60 100 / 0.05), 0 8px 24px rgb(30 60 100 / 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.row { display: flex; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.row.end { justify-content: flex-end; margin-top: 16px; }

.top { background: rgb(255 255 255 / 0.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.top-inner { display: flex; justify-content: space-between; align-items: center; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand svg { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.badge { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }

.btn {
  font: inherit; font-size: 14px; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn.sm { padding: 4px 10px; font-size: 13px; }

input[type="password"], input[type="search"], input[type="text"] {
  font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

main { padding-top: 24px; padding-bottom: 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.gate { max-width: 420px; margin: 48px auto; }
.gate form { margin-top: 16px; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.head input { max-width: 260px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 20px; margin-bottom: 16px;
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: center;
}
.dropzone strong { color: var(--accent); }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }

.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list li:hover { background: var(--accent-soft); }
.doc-icon { flex: none; width: 36px; height: 36px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.doc-main { flex: 1; min-width: 0; cursor: pointer; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-actions { display: flex; gap: 6px; }
.empty { text-align: center; padding: 32px; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; }
dialog::backdrop { background: rgb(20 40 70 / 0.35); backdrop-filter: blur(2px); }
.modal form { padding: 24px; width: min(380px, 90vw); }
.viewer { width: min(1100px, 96vw); height: 92vh; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.viewer-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer iframe { flex: 1; border: 0; width: 100%; background: #eef2f6; border-radius: 0 0 12px 12px; }

@media (max-width: 600px) {
  .head { flex-direction: column; align-items: stretch; }
  .head input { max-width: none; }
  .list li { flex-wrap: wrap; }
  .doc-actions { width: 100%; justify-content: flex-end; }
  .viewer-head { flex-direction: column; align-items: stretch; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; box-shadow: var(--shadow);
}
