/* RSA CRM — admin theme (custom, no framework). */
:root {
    --accent: #206bc4;
    --accent-dark: #1a579e;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #e6e8ec;
    --line-soft: #f0f1f3;
    --bg: #f5f6f8;
    --card: #ffffff;
    --danger: #c0392b;
    --radius: 7px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App shell ---- */
body.app { display: flex; align-items: stretch; min-height: 100vh; }
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: #1d273b;
    color: #aab4c8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { padding: 8px 0; flex: 1; }
.sidebar nav a {
    display: block;
    padding: 9px 18px;
    color: #aab4c8;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(32,107,196,.18); color: #fff; border-left-color: var(--accent); }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot .who { color: #8a94a8; margin-bottom: 6px; }
.sidebar-foot a { color: #cdd4e0; }

.content { flex: 1; min-width: 0; padding: 20px 24px; }
body.auth .content { flex: none; width: 100%; max-width: 400px; padding: 0 16px; }

/* ---- Headings ---- */
h1, h2, h3, h4 { margin: 0 0 .3rem; font-weight: 600; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
hgroup { margin-bottom: 18px; }
hgroup h2, hgroup h3 { margin-bottom: 2px; }
.muted { color: var(--muted); }
small.muted { font-size: 12px; }

/* ---- Cards (article) ---- */
article {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
article > header {
    font-weight: 600;
    margin: -14px -16px 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
.sort-ind { color: var(--accent); font-size: 11px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }

/* ---- Buttons ---- */
button, [role="button"], a.button {
    display: inline-block;
    font-size: 13px;
    font-family: inherit;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: #374151;
    cursor: pointer;
    line-height: 1.3;
    text-decoration: none;
    transition: background .12s, border-color .12s;
}
button:hover, [role="button"]:hover, a.button:hover { background: #f3f4f6; text-decoration: none; }
button:active { transform: translateY(1px); }

button[type="submit"], .primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
button[type="submit"]:hover, .primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.secondary { color: var(--muted); }
.contrast { color: var(--danger); border-color: #e3b4b4; }
.contrast:hover { background: #fbeeee; }
.outline { background: #fff; }

.row-actions button, .row-actions [role="button"] { padding: 4px 10px; font-size: 12px; margin-left: 4px; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; color: #374151; margin-bottom: 12px; }
input, select, textarea {
    display: block;
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    padding: 7px 9px;
    margin-top: 4px;
    border: 1px solid #d3d7de;
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
}
input[type="checkbox"] { width: auto; display: inline-block; margin: 0 6px 0 0; vertical-align: -1px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(32,107,196,.12); }
input[readonly] { background: #f3f4f6; color: var(--muted); }
textarea { min-height: 60px; }

/* ---- Layout helpers ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: start; }
[role="group"] { display: inline-flex; gap: 6px; }

/* ---- Status colors ---- */
.u-overdue { color: var(--danger); font-weight: 600; }
.u-soon { color: #b9770e; font-weight: 600; }
.u-ok { color: #1e7d34; }
.u-none { color: var(--muted); }

/* ---- Row tint by term proximity (warm = urgent, cool = far) ---- */
.row-overdue td { background: #f4b4b4; }
.row-overdue:hover td { background: #efa0a0; }
.row-d14 td { background: #ffcda6; }
.row-d14:hover td { background: #ffbd8c; }
.row-d30 td { background: #ffeaa6; }
.row-d30:hover td { background: #ffe187; }
.row-d60 td { background: #e6f1a8; }
.row-d60:hover td { background: #dbe98c; }
.row-d90 td { background: #c4eccb; }
.row-d90:hover td { background: #aee3b7; }
.row-far td { background: #c7e6f2; }
.row-far:hover td { background: #aedaea; }

/* ---- Metric cards on dashboard ---- */
.grid > article { margin-bottom: 0; }
.grid > article h3 { font-size: 26px; margin-bottom: 0; }

/* ---- Small screens ---- */
@media (max-width: 760px) {
    body.app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
    .sidebar nav { display: flex; flex-wrap: wrap; padding: 4px; }
    .sidebar nav a { border-left: none; border-radius: var(--radius); padding: 7px 12px; }
    .sidebar nav a.active { border-left: none; }
    .content { padding: 14px; }
}
