/* FileIT — application styles */
:root {
    --brand: #1f6feb;
    --brand-dark: #1a5fd0;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e2e6ee;
    --text: #1c2230;
    --muted: #6b7280;
    --success-bg: #e7f7ee; --success-fg: #0f7a3d;
    --error-bg: #fdecec;   --error-fg: #b42318;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 1px 2px rgba(20, 30, 50, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 9px; }
.topbar .brand .logo {
    width: 28px; height: 28px; border-radius: 7px; background: var(--brand);
    color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.topbar .user { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 14px; }

.shell { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
    width: 224px; background: var(--surface); border-right: 1px solid var(--border);
    padding: 18px 12px; flex-shrink: 0;
}
.sidebar .nav-group { margin-bottom: 20px; }
.sidebar .nav-group h4 {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); margin: 0 10px 8px;
}
.sidebar a {
    display: block; padding: 8px 10px; border-radius: 8px; color: var(--text);
    font-size: 14px; margin-bottom: 2px;
}
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--brand); color: #fff; font-weight: 600; }
.content { flex: 1; padding: 28px 32px; max-width: 1100px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .panel-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.panel .panel-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } .sidebar { display: none; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    background: var(--brand); color: #fff; border: 1px solid var(--brand);
    padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
    text-decoration: none; line-height: 1;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--error-fg); border-color: var(--error-fg); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--brand); border-color: transparent; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-row .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=color], select, textarea {
    width: 100%; padding: 9px 11px; 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: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.15); }
textarea { min-height: 84px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.inline-form { display: inline; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }

/* ---------- Badges / tags ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; }
.badge.gray { background: #6b7280; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; }
.tag-kind { opacity: .8; font-weight: 500; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.status-active { color: var(--success-fg); }
.status-archived { color: #b7791f; }
.status-destroyed { color: var(--error-fg); }

.file-number { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .02em; background: var(--bg); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: var(--success-bg); color: var(--success-fg); }
.flash.error { background: var(--error-bg); color: var(--error-fg); }
.flash.info { background: #eaf2ff; color: #1a5fd0; }

/* Company workspace context (sidebar) */
.company-context {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff; border-radius: 10px; padding: 12px 14px; margin: 0 4px 18px;
}
.company-context .cc-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.company-context .cc-name { font-size: 16px; font-weight: 700; margin: 2px 0 8px; line-height: 1.25; }
.company-context .cc-name.muted { color: rgba(255,255,255,.75); font-weight: 600; font-size: 14px; }
.company-context .cc-switch { color: #fff; font-size: 12px; font-weight: 600; opacity: .95; }
.company-context .cc-switch:hover { text-decoration: underline; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 40px rgba(20,30,50,.12); overflow: hidden; }
.auth-head { padding: 28px 28px 8px; text-align: center; }
.auth-head .logo-lg { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 800; margin: 0 auto 14px; }
.auth-head h1 { font-size: 20px; margin: 0 0 4px; }
.auth-head p { color: var(--muted); margin: 0; font-size: 14px; }
.auth-body { padding: 20px 28px 28px; }
.auth-foot { padding: 14px 28px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--muted); background: var(--bg); }

.muted { color: var(--muted); }
.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.text-right { text-align: right; }
.divider { height: 1px; background: var(--border); margin: 22px 0; border: none; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
