:root {
  --primary: #0b5fff;
  --primary-dark: #0846c0;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e7f0;
  --text: #1a2230;
  --muted: #6b7688;
  --danger: #d6332f;
  --success: #1a9e54;
  --warn: #c47f04;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,30,60,.08), 0 6px 18px rgba(20,30,60,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #0d1b39; color: #cdd6ea; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; font-weight: 700; color: #fff; font-size: 16px; }
.brand img { width: 30px; height: 30px; }
.navlink { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cdd6ea; cursor: pointer; font-weight: 500; }
.navlink:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.navlink.active { background: var(--primary); color: #fff; }
.navlink .ico { width: 18px; text-align: center; }
.nav-sep { margin: 10px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f7da0; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: #6f7da0; padding: 10px 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 17px; margin: 0; flex: 0 0 auto; }
.topbar .spacer { flex: 1; }
.usermenu { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; }
.content { padding: 22px; overflow: auto; }

/* Auth pages */
.auth-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 420px; padding: 32px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; color: var(--text); }
.auth-card h2 { margin: 4px 0 2px; text-align: center; }
.auth-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); font-size: 13px; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px;
  border: 1px solid transparent; border-radius: 8px; background: var(--primary); color: #fff;
  font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: #f0f3fa; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b3241f; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Cards & grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .num.warn { color: var(--warn); }
.stat .num.danger { color: var(--danger); }
.stat .num.ok { color: var(--success); }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { background: #f7f9fd; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfe; }
.table-wrap { overflow: auto; border-radius: var(--radius); }

/* File browser */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); flex-wrap: wrap; }
.breadcrumbs a { cursor: pointer; }
.filerow td .fname { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.ficon { width: 22px; text-align: center; font-size: 16px; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: var(--surface); margin-bottom: 16px; }
.dropzone.drag { border-color: var(--primary); background: #eef4ff; color: var(--primary); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.role-owner { background: #ffe8cc; color: #92500a; }
.badge.role-administrator { background: #dbe7ff; color: #1d4ed8; }
.badge.role-editor { background: #d6f5e3; color: #11703f; }
.badge.role-viewer { background: #eceff4; color: #54607a; }
.badge.ext { background: #fde2e1; color: #b3241f; }
.badge.ok { background: #d6f5e3; color: #11703f; }
.badge.bad { background: #fde2e1; color: #b3241f; }
.badge.warnb { background: #fff1cf; color: #92500a; }
.pill { padding: 1px 7px; border-radius: 6px; background: #eef1f7; font-size: 11px; color: var(--muted); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,22,40,.5); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal.lg { max-width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 20px; background: none; border: none; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #11203f; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; font-size: 13px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Context menu */
.ctxmenu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 150; min-width: 190px; }
.ctxmenu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: none; background: none; cursor: pointer; border-radius: 6px; font-size: 13px; text-align: left; color: var(--text); }
.ctxmenu button:hover { background: #f0f3fa; }
.ctxmenu button.danger { color: var(--danger); }
.ctxmenu .sep { height: 1px; background: var(--border); margin: 5px 2px; }

/* Misc */
.muted { color: var(--muted); }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.flexbtn { display:flex; gap:8px; align-items:center; }
.kvs { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; }
.kvs div.k { color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.checkline input { width: auto; }
code.mono { background: #f0f3fa; padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
pre.codeblock { background: #0d1b39; color: #cfe0ff; padding: 14px; border-radius: 8px; overflow: auto; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.active { color: var(--primary); border-color: var(--primary); }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .sidebar { flex-direction: row; flex-wrap: wrap; } .sidebar-foot { display:none; } }
