:root {
    --bg: #07090f;
    --surface: #0f1219;
    --surface2: #161b27;
    --border: #222840;
    --blue: #1a6bcc;
    --blue2: #4d94e0;
    --green: #10d98a;
    --amber: #f59e0b;
    --red: #f43f5e;
    --cyan: #06b6d4;
    --text: #eef0f8;
    --text2: #a0a9c4;
    --muted: #4a5278;

    /* Product Maturity sub-phase C: overridden per-tenant (see _Layout.cshtml's
       inline <style> block) - this default matches --surface exactly, so a
       tenant that hasn't picked a theme renders identically to before this
       phase existed. */
    --sidebar-bg: #0f1219;

    --sidebar-width: 230px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 58px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
}

body.lang-ar {
    font-family: 'Cairo', sans-serif;
}

body.lang-en {
    font-family: 'Inter', sans-serif;
}

a {
    color: inherit;
}

/* ---------- App shell ---------- */

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: width .2s ease;
    overflow-x: hidden;
}

/* Product Maturity sub-phase B: the collapsed state hides text labels and
   shrinks to an icon rail. The "collapsed" class lives on .app-shell (the
   shared parent of .sidebar and .main-area) so one class toggle drives
   both siblings. Uses the same inset-inline-start/margin-inline-start
   logical properties already in place, so it mirrors correctly in RTL
   with no extra rules. */
.app-shell.collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.app-shell.collapsed .sidebar-brand .brand-name,
.app-shell.collapsed .sidebar-brand .brand-sub,
.app-shell.collapsed .sidebar-tenant,
.app-shell.collapsed .sidebar-nav .nav-link span,
.app-shell.collapsed .sidebar-user .user-meta {
    display: none;
}

.app-shell.collapsed .sidebar-brand {
    padding-inline: 4px;
}

.app-shell.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding-inline: 0;
}

.app-shell.collapsed .sidebar-user {
    justify-content: center;
    padding-inline: 0;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text2);
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
}

.sidebar-brand {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.sidebar-brand .logo-box {
    width: 64px;
    height: 64px;
    background: #ffffff;
    border-radius: 12px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-brand .logo-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar-brand .logo-fallback {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: var(--blue);
}

.sidebar-brand .brand-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text);
}

.sidebar-brand .brand-name span {
    color: var(--blue2);
}

.sidebar-brand .brand-sub {
    font-size: 11px;
    color: var(--muted);
}

.sidebar-tenant {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-tenant .tenant-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-tenant .plan-badge {
    display: inline-block;
    margin-top: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--blue2);
    background: color-mix(in srgb, var(--blue) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
    border-radius: 6px;
    padding: 2px 8px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text2);
    text-decoration: none;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav .nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-nav .nav-link.active {
    background: color-mix(in srgb, var(--blue) 14%, transparent);
    color: var(--blue2);
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user .user-meta {
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 11px;
    color: var(--muted);
}

/* ---------- Main area ---------- */

.main-area {
    margin-inline-start: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-inline-start .2s ease;
}

.app-shell.collapsed .main-area {
    margin-inline-start: var(--sidebar-collapsed-width);
}

.topbar {
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.topbar .page-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.lang-toggle button {
    border: none;
    background: transparent;
    color: var(--text2);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    cursor: pointer;
}

.lang-toggle button.active {
    background: var(--blue);
    color: #fff;
}

/* ---------- Notification bell (Notifications phase, step 2) ---------- */
/* Plain <details>/<summary> toggle - no JS needed for open/close, matching
   the app's zero-per-page-JS-framework footprint. */

.notif-bell {
    position: relative;
}

.notif-bell > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text2);
    position: relative;
}

.notif-bell > summary::-webkit-details-marker {
    display: none;
}

.notif-bell > summary:hover {
    background: var(--surface2);
    color: var(--text);
}

.notif-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    text-align: center;
    padding: 0 3px;
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .4);
    z-index: 50;
}

.notif-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.notif-dropdown-header form button {
    background: none;
    border: none;
    color: var(--blue2);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.notif-item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text2);
    text-decoration: none;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: var(--surface2);
}

.notif-item.unread {
    color: var(--text);
    font-weight: 600;
    background: color-mix(in srgb, var(--blue) 8%, transparent);
}

.notif-item .notif-time {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
}

.notif-dropdown-footer {
    padding: 8px 14px;
    text-align: center;
    border-top: 1px solid var(--border);
}

.notif-dropdown-footer a {
    color: var(--blue2);
    font-size: 12px;
    text-decoration: none;
    font-weight: 600;
}

.notif-empty {
    padding: 20px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

.main-content {
    flex: 1;
    padding: 24px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
}

/* ---------- KPI cards ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 22px;
    height: 22px;
}

.kpi-icon.blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue2); }
.kpi-icon.green { background: rgba(16, 217, 138, 0.14); color: var(--green); }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.14); color: var(--amber); }
.kpi-icon.red { background: rgba(244, 63, 94, 0.14); color: var(--red); }

.kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.kpi-label {
    font-size: 12px;
    color: var(--text2);
    margin-top: 2px;
}

.card + .card {
    margin-top: 16px;
}

/* ---------- Kanban board ---------- */

.kanban-board {
    display: flex;
    flex-wrap: nowrap;
    gap: 14px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
}

.kanban-column {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    flex: 1 1 0;
    min-width: 220px;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.kanban-column-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}

.kanban-column-total {
    color: var(--text2);
    font-size: 11.5px;
    margin-bottom: 10px;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kanban-card {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
}

.kanban-card-number {
    font-weight: 700;
    font-size: 12.5px;
}

.kanban-card-supplier {
    color: var(--text2);
    font-size: 11.5px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
}

.kanban-card-due {
    color: var(--muted);
    font-size: 10.5px;
    margin-top: 4px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 14px;
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table th {
    text-align: start;
    color: var(--text2);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

table.data-table tbody tr:hover {
    background: var(--surface2);
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.badge-blue {
    background: color-mix(in srgb, var(--blue) 14%, transparent);
    color: var(--blue2);
}

.badge-green {
    background: rgba(16, 217, 138, 0.14);
    color: var(--green);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.14);
    color: var(--amber);
}

.badge-red {
    background: rgba(244, 63, 94, 0.14);
    color: var(--red);
}

.badge-muted {
    background: rgba(74, 82, 120, 0.2);
    color: var(--muted);
}

/* ---------- Forms ---------- */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease;
}

.form-control::placeholder {
    color: var(--muted);
}

.form-control:focus {
    border-color: var(--blue);
}

select.form-control {
    appearance: none;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
}

.btn-primary:hover {
    background: var(--blue2);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--muted);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text2);
}

.btn-ghost:hover {
    color: var(--text);
}

/* ---------- Theme presets (Product Maturity sub-phase C) ---------- */

.theme-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    border: 2px solid transparent;
    position: relative;
}

.theme-swatch.selected {
    border-color: var(--blue);
    background: var(--surface2);
}

.theme-swatch-preview {
    width: 56px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 6px;
}

.theme-swatch-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.theme-swatch-name {
    font-size: 10.5px;
    color: var(--text2);
    text-align: center;
    max-width: 72px;
}

/* ---------- Modals ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 9, 15, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 18px;
}
