:root {
  --bg: #f4f6f9; --card: #fff; --text: #14202e; --muted: #5d6b7c; --line: #dfe5ec; --brand: #0b4a8f; --brand-2: #0e63bf; --danger: #b3261e; --ok: #1a7f4b;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 32, 46, .06), 0 4px 14px rgba(20, 32, 46, .05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1722; --card: #17212e; --text: #e8eef5; --muted: #9aa8b8; --line: #263446; --brand: #5aa2ee; --brand-2: #7ab6f3; --danger: #ff8a80; --ok: #62d49a; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 800; letter-spacing: .02em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--muted); }
.top-search { flex: 1 1 220px; min-width: 160px; }
.top-search input { width: 100%; }
.top-nav { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
main { max-width: 1040px; margin: 0 auto; padding: 1rem; }

input, select, button, .btn { font: inherit; }
input[type=text], input[type=search], input[type=password], select { min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: .25rem .7rem; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: default; }
.stack { display: grid; gap: .8rem; max-width: 420px; }
.field { display: grid; gap: .3rem; }
.alert { padding: .7rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.alert.error { border-color: var(--danger); color: var(--danger); }

.cards { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 1rem; }
.card { display: block; padding: 1.1rem 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
a.card:hover { text-decoration: none; border-color: var(--brand-2); }
.card h3 { margin: 0 0 .3rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.badge.restricted { color: var(--danger); border-color: var(--danger); }

.crumbs { display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: center; margin: .2rem 0 .8rem; font-size: .95rem; }
.crumbs span.sep { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; align-items: center; gap: .75rem; padding: .65rem .9rem; border-top: 1px solid var(--line); min-height: 52px; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { overflow-wrap: anywhere; }
.list .sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.list .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.ext { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.ext.pdf { color: #c0392b; } .ext.doc, .ext.docx { color: #1f5fbf; } .ext.xls, .ext.xlsx { color: #1a7f4b; } .ext.dir { color: var(--brand); font-size: 1.25rem; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0 1rem; align-items: center; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: .9rem; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--brand-2); background: rgba(14, 99, 191, .08); }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: .4rem; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand-2); }

.grid-photos { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-photos a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.grid-photos img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
table { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .55rem .8rem; border-top: 1px solid var(--line); }
th { background: var(--bg); font-size: .85rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); max-width: 92vw; padding: .7rem 1.1rem; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 50; }
.toast.error { background: var(--danger); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); max-width: min(92vw, 460px); width: 100%; padding: 1.2rem; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
@media (max-width: 560px) { .list li { flex-wrap: wrap; } .top-nav { margin-left: 0; } }

.viewer-frame { display: block; width: 100%; height: calc(100vh - 230px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.viewer-media { text-align: center; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 78vh; border-radius: var(--radius); border: 1px solid var(--line); }
.viewer-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; max-height: 78vh; overflow: auto; }
