/* =========================================================
   Companies House Monitor - admin theme (Bootstrap 5 based)
   ========================================================= */
:root {
    --app-sidebar: #0f1b33;
    --app-sidebar-2: #16264a;
    --app-sidebar-text: #aab6cf;
    --app-sidebar-active: #ffffff;
    --app-accent: #2563eb;
    --app-accent-soft: #e8efff;
    --app-bg: #f3f5f9;
    --app-card: #ffffff;
    --app-border: #e4e8f0;
    --app-text: #1c2434;
    --app-muted: #6b7486;
    --app-sidebar-w: 260px;
    --app-topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--app-bg);
    color: var(--app-text);
    font-size: 14px;
}
a { color: var(--app-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- sidebar ---------------- */
.app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--app-sidebar-w);
    background: linear-gradient(180deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
    color: var(--app-sidebar-text);
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}
.app-brand {
    height: var(--app-topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    color: #fff; font-weight: 700; font-size: 15px;
    overflow: hidden; white-space: nowrap;
}
.app-brand:hover { text-decoration: none; color: #fff; }
.app-brand img { max-height: 36px; max-width: 46px; border-radius: 6px; background: #fff; padding: 2px; }
.app-brand .brand-mark {
    width: 36px; height: 36px; border-radius: 9px; flex: 0 0 36px;
    background: var(--app-accent); display: grid; place-items: center; font-size: 18px;
}
.app-brand span { overflow: hidden; text-overflow: ellipsis; }
.app-nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }
.app-nav .nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: #6f7d99; padding: 16px 10px 6px; font-weight: 600;
}
.app-nav a {
    display: flex; align-items: center; gap: 11px;
    color: var(--app-sidebar-text);
    padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
    font-weight: 500;
}
.app-nav a i { font-size: 17px; width: 20px; text-align: center; }
.app-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-nav a.active { background: var(--app-accent); color: var(--app-sidebar-active); box-shadow: 0 4px 14px rgba(37,99,235,.35); }
.app-nav .badge { margin-left: auto; }
.app-sidebar-footer { padding: 14px 20px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.06); color: #6f7d99; }

/* ---------------- main ---------------- */
.app-main { margin-left: var(--app-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
    height: var(--app-topbar-h);
    background: var(--app-card);
    border-bottom: 1px solid var(--app-border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 1030;
}
.app-topbar .page-title { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar .topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--app-border);
    background: #fff; display: grid; place-items: center; position: relative; color: var(--app-text);
}
.icon-btn:hover { background: var(--app-bg); }
.icon-btn .dot {
    position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; border: 2px solid #fff;
}
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 10px; border: 1px solid var(--app-border); background: #fff; color: var(--app-text); }
.user-chip:hover { text-decoration: none; background: var(--app-bg); }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--app-accent-soft); color: var(--app-accent); display: grid; place-items: center; font-weight: 700; }
.user-chip .uname { font-weight: 600; line-height: 1.1; }
.user-chip .urole { font-size: 11px; color: var(--app-muted); }
.notif-menu { width: 360px; max-height: 440px; overflow-y: auto; padding: 0; }
.notif-menu .notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--app-border); color: var(--app-text); }
.notif-menu .notif-item:hover { background: var(--app-bg); text-decoration: none; }
.notif-menu .notif-item.unread { background: #f5f8ff; }
.notif-menu .notif-item small { color: var(--app-muted); }

.app-content { padding: 24px; flex: 1; }
.app-footer { padding: 14px 24px; color: var(--app-muted); font-size: 12px; border-top: 1px solid var(--app-border); background: #fff; }

/* ---------------- components ---------------- */
.card { border: 1px solid var(--app-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--app-border); padding: 14px 18px; font-weight: 700; border-radius: 12px 12px 0 0 !important; display: flex; align-items: center; gap: 10px; }
.card-header .card-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 18px; }

.stat-card { padding: 18px; display: flex; flex-direction: row; gap: 14px; align-items: center; height: 100%; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: 0 0 48px; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { color: var(--app-muted); font-size: 13px; font-weight: 500; }
.bg-soft-primary { background: #e8efff; color: #2563eb; }
.bg-soft-success { background: #e3f8ee; color: #059669; }
.bg-soft-danger  { background: #fdecec; color: #dc2626; }
.bg-soft-warning { background: #fff4e0; color: #d97706; }
.bg-soft-info    { background: #e2f6fb; color: #0891b2; }
.bg-soft-secondary { background: #eef0f4; color: #4b5563; }

.form-label { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.form-control, .form-select { border-radius: 8px; border-color: #d6dce6; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--app-accent); box-shadow: 0 0 0 .2rem rgba(37,99,235,.15); }
.btn { border-radius: 8px; font-weight: 600; font-size: 14px; }
.btn-sm { font-size: 12.5px; }
.required:after { content: " *"; color: #dc2626; }

/* tables / gridview */
.table-app { margin: 0; }
.table-app > thead > tr > th, .table-app > tbody > tr > th {
    background: #f7f9fc; color: #4b5563; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 700; border-bottom: 1px solid var(--app-border); white-space: nowrap; padding: 11px 12px;
}
.table-app td { padding: 11px 12px; vertical-align: middle; border-color: var(--app-border); }
.table-app tr:hover td { background: #fafbfe; }
.table-app .pager td { background: #fff !important; }
.table-app .pager table td { padding: 0 2px; border: 0; }
.table-app .pager a, .table-app .pager span {
    display: inline-block; min-width: 32px; padding: 5px 9px; border-radius: 6px; border: 1px solid var(--app-border); text-align: center;
}
.table-app .pager span { background: var(--app-accent); color: #fff; border-color: var(--app-accent); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--app-muted); }
.empty-state i { font-size: 38px; display: block; margin-bottom: 8px; color: #c2c9d6; }

.badge { font-weight: 600; padding: .42em .7em; border-radius: 6px; }
.badge-soft-success { background: #e3f8ee; color: #047857; }
.badge-soft-danger { background: #fdecec; color: #b91c1c; }
.badge-soft-warning { background: #fff4e0; color: #b45309; }
.badge-soft-secondary { background: #eef0f4; color: #4b5563; }
.badge-soft-primary { background: #e8efff; color: #1d4ed8; }
.badge-soft-info { background: #e2f6fb; color: #0e7490; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; }
.kv dt { color: var(--app-muted); font-weight: 600; font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; }

/* repeater (multi-entry rows) */
.rep-row { border: 1px solid var(--app-border); border-radius: 10px; padding: 12px 12px 4px; margin-bottom: 10px; background: #fbfcfe; position: relative; }
.rep-row .rep-no { position: absolute; top: -10px; left: 12px; background: var(--app-accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 8px; }
.rep-row .rep-remove { position: absolute; top: 8px; right: 8px; }
.rep-row .form-label { font-size: 12px; color: var(--app-muted); }
.rep-empty { color: var(--app-muted); padding: 14px; border: 1px dashed #cfd6e2; border-radius: 10px; text-align: center; margin-bottom: 10px; }

/* compare */
.diff-old { background: #fff5f5; }
.diff-new { background: #f0fdf4; }
.section-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
    background: radial-gradient(circle at 20% 20%, #2a4a8f 0, transparent 40%), linear-gradient(135deg, #0f1b33 0%, #1d3567 100%);
    color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-art h1 { font-weight: 800; font-size: 34px; line-height: 1.2; max-width: 460px; }
.login-art p { color: #c3cde4; max-width: 440px; }
.login-art .feat { display: flex; gap: 10px; align-items: center; color: #dbe3f4; margin-bottom: 10px; }
.login-art .feat i { color: #7fb0ff; }
.login-form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login-box { width: 100%; max-width: 380px; }
.login-box .logo { max-height: 56px; margin-bottom: 18px; }

/* timeline (history) */
.timeline { position: relative; padding-left: 26px; }
.timeline:before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--app-border); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item:before { content: ""; position: absolute; left: -23px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--app-accent); }

/* ---------------- responsive ---------------- */
.sidebar-toggle { display: none; }
.app-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,27,51,.45); z-index: 1035; }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: grid; }
    .app-content { padding: 16px; }
    .app-topbar { padding: 0 16px; }
    .user-chip .uinfo { display: none; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dd { margin-bottom: 8px; }
    .notif-menu { width: 300px; }
}
@media print {
    .app-sidebar, .app-topbar, .app-footer, .no-print { display: none !important; }
    .app-main { margin: 0; }
}
