/* ============================================================
   BSLFORCE — Yantra India Limited
   Fluent 2 design language · brand maroon #991B46 (gear),
   orange #FA8E00 (hexagon), deep blue #1B5475 (tagline).
   ============================================================ */
:root {
    /* brand */
    --maroon: #991B46;
    --maroon-hover: #861640;
    --maroon-active: #741237;
    --maroon-dark: #62102F;
    --maroon-light: #E6A9BE;
    --orange: #FA8E00;
    --blue: #1B5475;

    /* semantic */
    --ink: #242424;          /* Fluent neutral foreground */
    --ink-2: #605E5C;        /* secondary foreground (labels, headers) */
    --accent: #991B46;
    --accent-2: #741237;
    --accent-soft: #F6E3EA;  /* light maroon tint */
    --bg: #f5f5f5;           /* Fluent canvas */
    --panel: #ffffff;
    --line: #e1dfdd;         /* Fluent neutral stroke */
    --line-strong: #c8c6c4;
    --muted: #605E5C;
    --text: #242424;
    --surface-2: #faf9f8;    /* Fluent subtle background */
    --topbar-bg: #ffffff;
    --input-bg: #ffffff;

    --ok: #0f7b0f;   --ok-bg: #dff6dd;
    --err: #a4262c;  --err-bg: #fde7e9;
    --warn: #c76b00; --warn-bg: #fff4e5;      /* brand orange family */
    --purple: #1B5475; --purple-bg: #e4eef4;  /* repurposed to brand blue */
    --teal: #038387; --teal-bg: #e0f3f3;
    --pink: #991B46; --pink-bg: #F6E3EA;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 .3px .9px rgba(0,0,0,.10), 0 .9px 1.8px rgba(0,0,0,.07);
    --shadow: 0 1.6px 3.6px rgba(0,0,0,.11), 0 .3px .9px rgba(0,0,0,.07);
    --shadow-lg: 0 6.4px 14.4px rgba(0,0,0,.13), 0 1.2px 3.6px rgba(0,0,0,.10);
    --sidebar-w: 280px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Segoe UI Variable", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
::selection { background: rgba(153,27,70,.18); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(96,94,92,.35); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(96,94,92,.55); background-clip: content-box; }

/* ======================= Layout ======================= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--panel);
    color: var(--ink);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    padding-bottom: 24px;
    border-inline-end: 1px solid var(--line);
}

.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px;
    position: sticky; top: 0;
    background: var(--panel);
    z-index: 2;
    border-bottom: 1px solid var(--line);
}
.brand-mark {
    width: 42px; height: 42px; border-radius: 8px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0;
    border: 1px solid var(--line);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark svg { width: 22px; height: 22px; color: var(--maroon); }
.brand-name { font-weight: 700; font-size: 17px; color: var(--maroon); letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }

.nav { padding: 8px 10px 0; }
.nav-group { padding: 15px 10px 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin: 1px 0;
    color: var(--ink); font-size: 14px; font-weight: 400;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
    position: relative;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-link:hover { background: rgba(0,0,0,.045); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--maroon); font-weight: 600; }
.nav-link.active svg { opacity: 1; color: var(--maroon); }
.nav-link.active::before {
    content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--maroon);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--topbar-bg);
    padding: 11px 24px; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--maroon);
    color: #fff; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.user-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.user-role { font-size: 10.5px; color: var(--maroon); background: var(--accent-soft); padding: 1px 8px; border-radius: 4px; align-self: flex-end; margin-top: 2px; font-weight: 600; }

.content { padding: 24px; max-width: 1320px; width: 100%; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ======================= Headings ======================= */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; color: var(--ink); font-weight: 600; letter-spacing: -.01em; }
.subtle { color: var(--muted); font-size: 13px; font-weight: 400; }

/* ======================= Panels / cards ======================= */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-pad { padding: 20px 22px; }
.panel-head { padding: 14px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); }
.panel-head h2 { margin: 0; font-size: 15px; color: var(--ink); font-weight: 600; }

/* ======================= Stat tiles ======================= */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
    display: flex; align-items: flex-start; gap: 14px;
    transition: box-shadow .15s, transform .15s;
    position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--maroon); opacity: .9; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-ico { width: 42px; height: 42px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--accent-soft); color: var(--maroon); }
.stat-ico svg { width: 21px; height: 21px; }
.stat-ico.green { background: var(--ok-bg); color: var(--ok); }
.stat-ico.red { background: var(--err-bg); color: var(--err); }
.stat-ico.amber { background: var(--warn-bg); color: var(--warn); }
.stat-ico.purple { background: var(--purple-bg); color: var(--purple); }
.stat-ico.teal { background: var(--teal-bg); color: var(--teal); }
.stat-body { min-width: 0; }
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--ink); margin-top: 2px; line-height: 1.1; letter-spacing: -.02em; }
.stat .value.ok { color: var(--ok); }
.stat .value.err { color: var(--err); }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ======================= Grid helpers ======================= */
.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

/* ======================= Tables ======================= */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:hover { background: rgba(153,27,70,.045); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.wrap, table.grid th.wrap { white-space: normal; }
.muster td, .muster th { padding: 6px 7px; text-align: center; font-size: 11px; }
.muster tbody tr:hover { background: rgba(153,27,70,.045); }

/* ======================= Badges ======================= */
.badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.red { background: var(--err-bg); color: var(--err); }
.badge.amber { background: var(--warn-bg); color: var(--warn); }
.badge.grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.blue { background: var(--accent-soft); color: var(--maroon); }
.mark-P { color: var(--ok); font-weight: 700; }
.mark-HD { color: var(--warn); font-weight: 700; }
.mark-A { color: var(--err); font-weight: 700; }
.mark-WO { color: var(--muted); }
.mark-PH { color: var(--blue); font-weight: 600; }

/* ======================= Buttons ======================= */
.btn {
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    border: 1px solid var(--maroon); border-radius: var(--radius-sm);
    padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    background: var(--maroon); color: #fff;
    transition: background .12s, border-color .12s;
    font-family: inherit; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--maroon-hover); border-color: var(--maroon-hover); color: #fff; text-decoration: none; }
.btn:active { background: var(--maroon-active); border-color: var(--maroon-active); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--maroon); border-color: var(--maroon); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-danger:hover { background: #8a1f24; border-color: #8a1f24; }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #0b5e0b; border-color: #0b5e0b; }
/* Clear / reset filter button — muted by default, turns red on hover to signal removal */
.btn-clear { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.btn-clear:hover { color: var(--err); border-color: var(--err); background: var(--panel); }
.inline { display: inline; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ======================= Forms ======================= */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field input[type=text], .field input[type=password], .field input[type=number],
.field input[type=date], .field input[type=datetime-local], .field input[type=time],
.field select, .field textarea, input.ctl, select.ctl {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-size: 14px; background: var(--input-bg); font-family: inherit; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus, .ctl:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 1px var(--maroon); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--maroon); }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.filters .field { min-width: 150px; margin: 0; }
.filters .btn, .filters .btn-ghost { margin-bottom: 1px; }

/* ======================= Alerts ======================= */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; border: 1px solid transparent; border-inline-start-width: 3px; display: flex; align-items: center; gap: 9px; animation: fadeUp .25s ease; }
.alert::before { font-weight: 700; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #a7d8a7; }
.alert-ok::before { content: "\2713"; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f1b9bc; }
.alert-err::before { content: "!"; }
.validation { color: var(--err); font-size: 12.5px; }
.field .validation { margin-top: 3px; }

/* ======================= Login (brand background + form card) ======================= */
.login-wrap {
    min-height: 100vh; display: flex; align-items: stretch; justify-content: flex-end;
    padding: 0; position: relative; background: #fff;
}
/* Image panel fills everything left of the 460px form card, so the gate photo fits its own area. */
.login-wrap::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: 460px;
    background: linear-gradient(135deg, rgba(98,16,47,.32), rgba(27,84,117,.28)), url('/img/ofbh-gate.jpg');
    background-size: cover; background-position: center;
}
.login-card { background: var(--panel); width: 460px; max-width: 460px; min-height: 100vh; border-radius: 0; box-shadow: -14px 0 40px rgba(0,0,0,.22); padding: 56px 48px; position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; animation: fadeUp .3s ease; }
.login-logo { width: 72px; height: 72px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; overflow: hidden; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-logo svg { width: 34px; height: 34px; color: var(--maroon); }
.login-card h1 { margin: 0 0 4px; font-size: 24px; color: var(--maroon); font-weight: 700; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }
.login-hint { margin-top: 16px; }

/* ======================= Misc ======================= */
.empty { text-align: center; color: var(--muted); padding: 34px; }
.pill-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 12px; }
.device-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot-online { background: var(--ok); box-shadow: 0 0 0 3px rgba(15,123,15,.15); }
.dot-offline { background: #a19f9d; }
.dot-error { background: var(--err); box-shadow: 0 0 0 3px rgba(164,38,44,.15); }
.row-split { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row-split:last-child { border-bottom: none; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px 18px; }
.perm-group-title { grid-column: 1/-1; font-weight: 700; color: var(--maroon); margin-top: 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }

.live-pill { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; border-radius: 4px; background: var(--surface-2); transition: background .3s; }
.live-pill.flash { background: var(--ok-bg); color: var(--ok); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(15,123,15,.15); animation: livePulse 1.6s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.minibar { height: 7px; background: var(--surface-2); border-radius: 20px; overflow: hidden; margin-top: 5px; }
.minibar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--maroon), var(--orange)); border-radius: 20px; }

/* ======================= Home / module cards (BSLFORCE-style) ======================= */
.home-hero { text-align: center; padding: 10px 0 26px; }
.home-hero img { width: min(20rem, 70vw); height: auto; }
.home-hero h1 { font-size: 26px; color: var(--ink); font-weight: 600; margin: 18px 0 6px; }
.home-hero p { color: var(--muted); font-size: 14px; max-width: 640px; margin: 0 auto; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.module-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: box-shadow .15s, transform .15s; }
.module-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.module-card h3 { margin: 0; font-size: 16px; color: var(--maroon); font-weight: 600; }
.module-card p { margin: 0; font-size: 13px; color: var(--muted); flex: 1; }

/* ======================= Theme toggle ======================= */
.theme-toggle { padding: 7px 9px; }
.theme-toggle svg { width: 16px; height: 16px; display: block; }

/* ======================= Dark theme (Fluent 2 dark + maroon tint) ======================= */
:root[data-theme="dark"] {
    --ink: #ffffff;
    --ink-2: #c8c6c4;
    --accent: #E0678F;
    --accent-2: #EE93AF;
    --accent-soft: rgba(224,103,143,.16);
    --maroon: #E0678F;
    --maroon-hover: #E8809F;
    --maroon-active: #EE93AF;
    --bg: #1b1a19;
    --panel: #292827;
    --line: #3b3a39;
    --line-strong: #4d4b49;
    --muted: #a19f9d;
    --text: #f3f2f1;
    --surface-2: #323130;
    --topbar-bg: #292827;
    --input-bg: #1f1e1d;
    --ok: #4ac94a; --ok-bg: rgba(15,123,15,.26);
    --err: #f1707b; --err-bg: rgba(164,38,44,.28);
    --warn: #fbbf24; --warn-bg: rgba(199,107,0,.26);
    --purple: #6fb3d8; --purple-bg: rgba(27,84,117,.3);
    --teal: #4ec5c8; --teal-bg: rgba(3,131,135,.26);
    --pink: #E0678F; --pink-bg: rgba(224,103,143,.2);
    --shadow-sm: 0 .3px .9px rgba(0,0,0,.4);
    --shadow: 0 1.6px 3.6px rgba(0,0,0,.5);
    --shadow-lg: 0 6.4px 14.4px rgba(0,0,0,.6);
}
:root[data-theme="dark"] body { background: var(--bg); }
:root[data-theme="dark"] .brand-name { color: var(--maroon); }
:root[data-theme="dark"] .btn { color: #1b1a19; }
:root[data-theme="dark"] .btn-ghost { color: var(--ink); }
:root[data-theme="dark"] .btn-ghost:hover { color: var(--maroon); }
:root[data-theme="dark"] .avatar { color: #1b1a19; }
:root[data-theme="dark"] .login-card { box-shadow: -12px 0 40px rgba(0,0,0,.6); }

/* ======================= Responsive ======================= */
@media (max-width: 980px) {
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { width: 64px; }
    .brand-name, .brand-sub, .nav-group { display: none; }
    .brand { justify-content: center; padding: 14px 0; }
    .nav-link { justify-content: center; padding: 11px 0; }
    .nav-link span { display: none; }
    .nav-link.active::before { left: 0; }
    .user-meta { display: none; }
    .content { padding: 16px 14px; }
    .login-wrap::before { display: none; }
    .login-card { width: 100%; max-width: 100%; }
}
