/* ==========================================================================
   Neta by Grix — Premium RTL design system
   Palette sampled from the Grix logo.
   ========================================================================== */

:root {
    /* Brand */
    --grix-cyan: #0DA2CA;
    --grix-blue: #1066B5;
    --grix-blue-600: #0F5CA3;
    --grix-navy: #012A7B;
    --grix-green: #18BE66;
    --grix-lime: #4BC140;
    --grix-orange: #FC952F;

    /* Gradients */
    --grad-brand: linear-gradient(135deg, #0DA2CA 0%, #1066B5 55%, #012A7B 100%);
    --grad-brand-soft: linear-gradient(135deg, rgba(13,162,202,.12), rgba(16,102,181,.12));
    --grad-sidebar: linear-gradient(185deg, #032F86 0%, #012160 100%);
    --grad-success: linear-gradient(135deg, #18BE66, #4BC140);
    --grad-orange: linear-gradient(135deg, #FCA847, #FC8A1E);

    /* Neutrals */
    --ink: #0F2033;
    --ink-2: #2b3f56;
    --muted: #64748b;
    --line: #e6ecf3;
    --line-2: #eef2f7;
    --bg: #f2f6fb;
    --card: #ffffff;

    /* Status */
    --ok: #16a34a;
    --ok-bg: #e7f8ee;
    --warn: #d97706;
    --warn-bg: #fdf1e1;
    --danger: #dc2626;
    --danger-bg: #fdecec;
    --info: #1066B5;
    --info-bg: #e8f1fb;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(1, 42, 123, .06), 0 1px 3px rgba(1, 42, 123, .06);
    --shadow: 0 6px 20px rgba(1, 42, 123, .08);
    --shadow-lg: 0 18px 50px rgba(1, 42, 123, .16);
    --ring: 0 0 0 4px rgba(16, 102, 181, .16);

    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 9px;
    --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Heebo", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, .display {
    font-family: "Rubik", "Heebo", sans-serif;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0 0 .4em;
}

a { color: var(--grix-blue); text-decoration: none; }
a:hover { color: var(--grix-navy); }

.muted { color: var(--muted); }
.text-center { text-align: center; }
.small { font-size: .82rem; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--grad-sidebar);
    color: #dfe8ff;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0; /* RTL: right edge */
    display: flex;
    flex-direction: column;
    z-index: 40;
    box-shadow: var(--shadow-lg);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid rgba(255,255,255,.09);
}
.sidebar__brand img { width: 40px; height: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
.sidebar__brand .name { font-family: "Rubik"; font-weight: 700; font-size: 1.28rem; color: #fff; line-height: 1; }
.sidebar__brand .sub { font-size: .72rem; color: #9fb6e8; letter-spacing: .12em; text-transform: uppercase; }

.sidebar__scope {
    margin: 16px 16px 4px;
    padding: 12px 14px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius-sm);
    font-size: .8rem;
}
.sidebar__scope .label { color: #9fb6e8; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; }
.sidebar__scope .value { color: #fff; font-weight: 600; font-size: .95rem; margin-top: 2px; }

/* impersonation (platform owner acting inside a tenant) */
.imp-banner {
    margin: 16px 16px 4px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(252,149,47,.20), rgba(252,138,30,.14));
    border: 1px solid rgba(252,149,47,.45);
    border-radius: var(--radius-sm);
}
.imp-banner__label { display: flex; align-items: center; gap: 7px; color: #ffd9ab; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.imp-banner__label svg { width: 15px; height: 15px; }
.imp-banner__tenant { color: #cddbf7; font-size: .74rem; margin-top: 8px; }
.imp-banner__name { color: #fff; font-weight: 700; font-size: 1.02rem; font-family: "Rubik"; line-height: 1.2; }
.imp-banner__exit {
    display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%;
    margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-xs); cursor: pointer;
    background: #fff; color: #b4620c; border: 0; font: inherit; font-weight: 600; font-size: .84rem;
    transition: background .16s ease;
}
.imp-banner__exit:hover { background: #fff4e7; }
.imp-banner__exit svg { width: 16px; height: 16px; }

.nav { padding: 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav__section { color: #7f9adb; font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; padding: 14px 14px 6px; }
.nav__link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-xs);
    color: #cddbf7;
    font-weight: 500;
    transition: all .16s ease;
    position: relative;
}
.nav__link svg { width: 20px; height: 20px; flex: 0 0 20px; opacity: .9; }
.nav__link:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav__link.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.nav__link.active::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 18%; bottom: 18%;
    width: 3px; border-radius: 3px; background: linear-gradient(var(--grix-cyan), var(--grix-green));
}

.sidebar__foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.09); }

.main {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--sidebar-w);
    display: flex; flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 14px 30px;
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(1.2) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.22rem; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: .8rem; }

.content { padding: 28px 30px 48px; max-width: 1200px; width: 100%; }

/* user menu */
.usermenu { position: relative; }
.usermenu__btn {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--line);
    border-radius: 40px; padding: 6px 8px 6px 14px; cursor: pointer;
    transition: all .16s ease;
}
.usermenu__btn:hover { box-shadow: var(--shadow-sm); border-color: #d3deec; }
.usermenu__btn .who { display: flex; flex-direction: column; text-align: start; line-height: 1.2; }
.usermenu__btn .who .n { font-weight: 600; font-size: .86rem; }
.usermenu__btn .who .r { font-size: .72rem; color: var(--muted); }
.usermenu__panel {
    position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); min-width: 220px; padding: 8px; display: none;
}
.usermenu.open .usermenu__panel { display: block; }
.usermenu__panel a, .usermenu__panel button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border-radius: var(--radius-xs);
    background: none; border: 0; cursor: pointer; color: var(--ink); font: inherit; text-align: start;
}
.usermenu__panel a:hover, .usermenu__panel button:hover { background: var(--bg); }
.usermenu__sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* avatar */
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--grad-brand); color: #fff; font-weight: 700; font-size: .9rem;
    font-family: "Rubik"; flex: 0 0 auto; box-shadow: var(--shadow-sm);
}
.avatar.lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar.sm { width: 30px; height: 30px; font-size: .74rem; }

/* ==========================================================================
   Cards, stats
   ========================================================================== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 22px; border-bottom: 1px solid var(--line-2);
}
.card__head h2, .card__head h3 { margin: 0; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 8px; }
.card__head h2 svg, .card__head h3 svg { flex: 0 0 auto; }
.card__body { padding: 22px; }
.card__body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.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); }

.stat {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
}
.stat__icon {
    width: 46px; height: 46px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: 14px;
}
.stat__icon svg { width: 24px; height: 24px; }
.stat__icon.blue { background: var(--grad-brand); }
.stat__icon.green { background: var(--grad-success); }
.stat__icon.orange { background: var(--grad-orange); }
.stat__icon.cyan { background: linear-gradient(135deg, #22C4E8, #0DA2CA); }
.stat__value { font-family: "Rubik"; font-size: 2rem; font-weight: 700; line-height: 1; }
.stat__label { color: var(--muted); font-size: .86rem; margin-top: 6px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: .9rem;
    padding: 10px 18px; border-radius: var(--radius-xs);
    border: 1px solid transparent; cursor: pointer;
    transition: transform .12s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
    white-space: nowrap; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 6px 16px rgba(16,102,181,.28); }
.btn-primary:hover { color: #fff; box-shadow: 0 10px 22px rgba(16,102,181,.36); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: #cdd9e8; background: var(--bg); color: var(--ink); }
.btn-success { background: var(--grad-success); color: #fff; box-shadow: 0 6px 16px rgba(24,190,102,.26); }
.btn-success:hover { color:#fff; box-shadow: 0 10px 22px rgba(24,190,102,.34); }
.btn-danger { background: #fff; border-color: #f3c9c9; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-warn { background: #fff; border-color: #f2d7ac; color: var(--warn); }
.btn-warn:hover { background: var(--warn-bg); }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-lg { padding: 13px 24px; font-size: 1rem; }

.btn-icon {
    width: 34px; height: 34px; padding: 0; border-radius: 9px;
    background: #fff; border: 1px solid var(--line); color: var(--ink-2);
}
.btn-icon:hover { background: var(--bg); border-color: #cdd9e8; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
    text-align: start; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600; padding: 14px 18px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.tbl td { padding: 14px 18px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr { transition: background .12s ease; }
table.tbl tbody tr:hover { background: #f8fbff; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user .n { font-weight: 600; }
.cell-user .e { font-size: .8rem; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ==========================================================================
   Badges / chips
   ========================================================================== */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .76rem; font-weight: 600; padding: 4px 11px; border-radius: 40px; line-height: 1.4;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-muted { color: var(--muted); background: #eef2f7; }
.chip-role { font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 7px; background: var(--grad-brand-soft); color: var(--grix-navy); }
.chip-role.admin { background: rgba(252,149,47,.14); color: #b4620c; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-row { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
label.lbl { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 7px; color: var(--ink-2); }
label.lbl .req { color: var(--danger); }
.control, input.control, select.control {
    width: 100%; padding: 11px 14px; font: inherit; color: var(--ink);
    background: #fff; border: 1px solid #d8e1ec; border-radius: var(--radius-xs);
    transition: border-color .16s ease, box-shadow .16s ease;
}
.control:focus { outline: none; border-color: var(--grix-blue); box-shadow: var(--ring); }
.control::placeholder { color: #9aa9ba; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 6px; }
.input-pw { position: relative; }
/* Reserve room for the eye toggle (sits at the physical-left in this RTL app) so
   the password text — RTL or LTR (dir="ltr") — never runs under it. */
.input-pw .control { padding-left: 44px; }
.input-pw .toggle {
    position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 7px;
}
.input-pw .toggle:hover { background: var(--bg); color: var(--ink); }

.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .9rem; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--grix-blue); }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 13px 16px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert svg { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; }
.alert-ok { background: var(--ok-bg); color: #0f7a3d; border-color: #bce7cd; }
.alert-danger { background: var(--danger-bg); color: #a81f1f; border-color: #f4cccc; }
.alert-info { background: var(--info-bg); color: #0c4c8f; border-color: #cadffb; }
.alert-warn { background: var(--warn-bg); color: #9a5a06; border-color: #f2d7ac; }
.alert ul { margin: 4px 0 0; padding-inline-start: 18px; }

/* ==========================================================================
   Page header + misc
   ========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .t { font-size: 1.5rem; margin: 0; }
.page-head .d { color: var(--muted); margin: 4px 0 0; }

.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; opacity: .4; margin-bottom: 14px; }

.divider { height: 1px; background: var(--line); margin: 22px 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.tag-copy { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .82rem; background: var(--bg); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }

/* ==========================================================================
   Integration tiles
   ========================================================================== */
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.int-tile {
    position: relative; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 26px 20px 20px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    text-decoration: none; color: var(--ink);
    transition: transform .14s ease, box-shadow .16s ease, border-color .16s ease;
}
a.int-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cdd9e8; }
.int-tile__logo { width: 76px; height: 76px; display: flex; align-items: center; justify-content: center; }
.int-tile__logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.int-tile__name { font-family: "Rubik"; font-weight: 600; font-size: 1.08rem; }
.int-tile__status { margin-top: 2px; }
.int-tile.is-disabled { cursor: not-allowed; }
.int-tile.is-disabled .int-tile__logo { filter: grayscale(1); opacity: .5; }
.int-tile.is-disabled .int-tile__name { color: var(--muted); }
.int-tile.is-connected { border-color: #bce7cd; box-shadow: 0 0 0 1px #bce7cd inset; }
.int-tile__corner {
    position: absolute; inset-block-start: 12px; inset-inline-start: 12px;
    display: inline-flex; align-items: center; gap: 5px;
}

/* copy row (token / webhook url) */
.copy-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.copy-row code {
    flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
    background: #0f172a; color: #e2e8f0; border-radius: 8px;
    padding: 10px 12px; font-family: ui-monospace, monospace; font-size: .85rem;
}

/* Priority webhook setup steps */
.setup-section { font-weight: 700; color: var(--ink); margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); }
.setup-section:first-child { margin-top: 0; }
.setup-steps { margin: 6px 0 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; }
.setup-steps li { line-height: 1.6; }
.setup-paths { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.setup-paths li { background: #f4f7fb; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; line-height: 1.7; }

/* last-synced emphasis chip */
.sync-chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--info-bg); color: var(--info);
    border: 1px solid #cadffb; border-radius: 40px;
    padding: 7px 14px; font-weight: 600; font-size: .88rem; white-space: nowrap;
}
.sync-chip svg { width: 16px; height: 16px; }

/* password meter */
.pw-meter { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 8px; }
.pw-meter > span { display: block; height: 100%; width: 0; transition: width .2s ease, background .2s ease; }

/* ==========================================================================
   Auth (login / change password) split screen
   ========================================================================== */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
    background: var(--bg);
}
.auth__brand {
    background: var(--grad-brand); color: #fff; position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 60px;
}
.auth__brand::after {
    content: ""; position: absolute; inset: 0;
    background:
        radial-gradient(600px 300px at 15% 15%, rgba(75,193,64,.35), transparent 60%),
        radial-gradient(500px 300px at 90% 85%, rgba(252,149,47,.30), transparent 55%);
    opacity: .9;
}
.auth__brand > * { position: relative; z-index: 1; }
.auth__hero { display: flex; flex-direction: column; align-items: center; }
.auth__hero img { width: 140px; height: 140px; filter: drop-shadow(0 10px 28px rgba(0,0,0,.3)); margin-bottom: 24px; }
.auth__hero-name { font-family: "Rubik"; font-weight: 700; color: #fff; font-size: 4.4rem; line-height: 1; letter-spacing: -.02em; }
.auth__hero-sub { font-size: 1.2rem; letter-spacing: .3em; text-transform: uppercase; color: #cfe0ff; margin-top: 12px; }

.auth__panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth__card { width: 100%; max-width: 400px; }
.auth__card h1 { font-size: 1.7rem; margin-bottom: 6px; }
.auth__card .lead { color: var(--muted); margin-bottom: 28px; }
.auth__mobilelogo { display: none; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth__mobilelogo img { width: 44px; height: 44px; }
.auth__mobilelogo .name { font-family: "Rubik"; font-weight: 700; font-size: 1.4rem; }

/* ==========================================================================
   Responsive
   ========================================================================== */
.menu-toggle { display: none; }
@media (max-width: 980px) {
    .auth { grid-template-columns: 1fr; }
    .auth__brand { display: none; }
    .auth__mobilelogo { display: flex; }
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: 1fr; }
    .grid.cols-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(100%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-inline-start: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 20px 16px 40px; }
    .topbar { padding: 12px 16px; }
}

/* scrim for mobile sidebar */
.scrim { display: none; position: fixed; inset: 0; background: rgba(1,20,50,.4); z-index: 35; }
.scrim.show { display: block; }
