/* Maxima Sync Console — dashboard styles */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #f4f6fa; color: #1f2430; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; background: linear-gradient(180deg,#0f172a 0%,#1e293b 100%);
    color: #e5e7eb; padding: 20px 0; flex-shrink: 0;
}
.sidebar-header { padding: 0 20px 16px; border-bottom: 1px solid #334155; margin-bottom: 10px; }
.sidebar-header h3 { margin: 0; font-size: 20px; color: #fff; }
.sidebar-header .sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li { margin: 2px 0; }
.sidebar-menu a, .sidebar-menu input[type=submit] { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #cbd5e1; border-left: 3px solid transparent; font-size: 14px; background: transparent; border: 0; width: 100%; text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none; }
.sidebar-menu .icon  { display: inline-block; width: 20px; text-align: center; flex-shrink: 0; font-size: 16px; }
.sidebar-menu .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-menu .logout-link { color: #fca5a5 !important; }
.sidebar-menu .logout-link:hover { background: #7f1d1d !important; color: #fff !important; }
.sidebar-menu .logout-link .icon { font-weight: 700; }
.sidebar-menu a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar-menu a.active { background: #1e293b; color: #fff; border-left-color: #3b82f6; }

.main-content { flex: 1; padding: 0; min-width: 0; }
.header { background: #fff; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 5; }
.header h1 { font-size: 20px; margin: 0; }
.user-info { font-size: 14px; color: #475569; }
.mobile-menu-toggle { display: none; background: #1e293b; color: white; border: 0; padding: 8px 12px; border-radius: 6px; font-size: 18px; cursor: pointer; }
.sidebar-collapse-toggle { background: #1e293b; color: white; border: 0; padding: 8px 12px; border-radius: 6px; font-size: 16px; cursor: pointer; margin-right: 12px; }
.sidebar-collapse-toggle:hover { background: #0f172a; }

/* Collapsed sidebar: narrow icon-only rail */
.sidebar { transition: width 0.18s ease; }
html.sb-collapsed .sidebar { width: 64px; }
html.sb-collapsed .sidebar-header h3,
html.sb-collapsed .sidebar-header .sub { display: none; }
html.sb-collapsed .sidebar-header { padding: 8px 0 10px; text-align: center; border-bottom-color: #1e293b; }
html.sb-collapsed .sidebar-header::before { content: "≡"; font-size: 22px; color: #94a3b8; }
html.sb-collapsed .sidebar-menu .label { display: none; }
html.sb-collapsed .sidebar-menu a,
html.sb-collapsed .sidebar-menu input[type=submit] { justify-content: center; padding: 12px 0; gap: 0; }
html.sb-collapsed .sidebar-menu .icon { font-size: 20px; width: auto; }

.container { padding: 24px; }

.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid #e5e7eb; margin-bottom: 20px; }
.card h2 { margin: 0 0 16px; font-size: 18px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: 10px; padding: 16px 20px; border: 1px solid #e5e7eb; }
.stat .v { font-size: 26px; font-weight: 600; color: #0f172a; }
.stat .l { font-size: 12px; color: #64748b; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat.ok .v { color: #059669; }
.stat.warn .v { color: #d97706; }
.stat.bad .v { color: #dc2626; }

input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; background: #fff; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #3b82f6; outline-offset: 0; border-color: #3b82f6; }
label { font-size: 13px; color: #475569; display: block; margin-bottom: 4px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row .col-sm { flex: 0 1 120px; }

.btn { display: inline-block; padding: 9px 16px; border-radius: 6px; border: 0; cursor: pointer; font-size: 14px; font-weight: 500; background: #2563eb; color: #fff; }
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #e2e8f0; color: #0f172a; }
.btn.secondary:hover { background: #cbd5e1; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.warn { background: #f59e0b; }
.btn.small { padding: 4px 10px; font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
table.data thead th { background: #f1f5f9; text-align: left; padding: 10px; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; font-weight: 600; color: #334155; }
table.data tbody td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.ok   { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad  { background: #fee2e2; color: #991b1b; }
.pill.pending { background: #e0e7ff; color: #3730a3; }
.pill.neutral { background: #e5e7eb; color: #334155; }

.msg  { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.msg.ok   { background: #dcfce7; color: #166534; }
.msg.err  { background: #fee2e2; color: #991b1b; }
.msg.info { background: #dbeafe; color: #1e40af; }

/* Login page */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg,#1e293b 0%,#0f172a 100%); }
.login-box { width: 360px; background: #fff; border-radius: 14px; padding: 34px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box .sub { color: #64748b; margin-bottom: 20px; font-size: 13px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 15px; }

@media (max-width: 820px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; transition: left 0.2s; z-index: 50; }
    .sidebar.active { left: 0; }
    .mobile-menu-toggle { display: inline-block; }
    .header { justify-content: flex-start; gap: 12px; }
}

/* =========================================================
   Dashboard v2 — redesigned toolbar + compact table
   ========================================================= */
.toolbar-card { padding: 14px 16px; }
/* Two-row toolbar: row 1 = inputs (search + filter + search btn), row 2 = actions */
.toolbar { display: grid; grid-template-columns: 1fr auto auto auto auto auto; gap: 10px 12px; align-items: end; }
.toolbar-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.toolbar-group label { margin: 0; font-size: 11px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; }
.toolbar-group.grow { grid-column: 1 / 2; }
.toolbar-group.grow input[type=text] { width: 100%; }
.toolbar-group select { height: 38px; min-width: 180px; }
.toolbar-group .btn { height: 38px; white-space: nowrap; }
.toolbar-group.primary-actions .btn, .toolbar-group.tools .btn { min-width: 160px; }
.tools-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 12px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; }

/* On narrow screens wrap to two rows cleanly */
@media (max-width: 1100px) {
    .toolbar { grid-template-columns: 1fr 1fr; }
    .toolbar-group.grow { grid-column: 1 / -1; }
}

.health-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); }

table.data.compact { font-size: 12.5px; }
table.data.compact thead th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: #64748b; padding: 8px 10px; }
table.data.compact thead th.group-head { color: #0f172a; font-size: 12px; text-transform: none; }
table.data.compact tbody td { padding: 6px 10px; vertical-align: middle; }
table.data.compact td.col-model { font-weight: 600; color: #0f172a; }
table.data.compact td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: #64748b; }
table.data.compact td.small-col { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data.compact .cell-stack { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
table.data.compact .cell-main { font-weight: 600; font-size: 13px; color: #0f172a; text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact .cell-sub  { font-size: 11px; color: #64748b; text-align: right; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

/* 🚩 red row */
table.data tr.row-flag td { background: #fef2f2 !important; }
table.data tr.row-flag:hover td { background: #fee2e2 !important; }
table.data td.flag-cell { text-align: center; padding-left: 4px; padding-right: 4px; }

/* Per-row actions menu (popover) */
.actions-cell { text-align: right; position: relative; }
.actions-menu { position: relative; display: inline-block; }
.actions-menu > .btn { min-width: 32px; }
.actions-pop { position: absolute; right: 0; top: 100%; margin-top: 4px; z-index: 10; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: none; flex-direction: column; gap: 4px; min-width: 150px; }
.actions-pop.open { display: flex; }
.actions-pop .btn { width: 100%; text-align: left; }
