:root {
    --navy: #003399;
    --teal: #105751;
    --teal-dark: #073B36;
    --teal-light: #26776F;
    --border: #d7e0df;
    --surface: #ffffff;
    --surface-alt: #f5f8f7;
    --bg: #eceeef;
    --text: #1f2a29;
    --muted: #6b7a78;
    --focus: #6ECCC4;
    --danger: #c0392b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

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

a { color: var(--teal-light); text-decoration: none; }
a:hover { color: var(--teal-dark); text-decoration: underline; }

/* ---------- Layout shell ---------- */
div.page {
    max-width: 1200px;
    margin: 24px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

div.page h1 {
    background: var(--navy);
    margin: 0;
    padding: 16px 20px;
    color: white;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: .5px;
}

div.page div.navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 2px;
    background: var(--surface-alt);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
}

div.page div.navigation a {
    color: var(--teal);
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}
div.page div.navigation a:hover { background: #e2edeb; text-decoration: none; }

div.page h2 {
    margin: 0 0 16px 0;
    color: var(--teal);
    font-size: 1.25rem;
    font-weight: 600;
}

div.page div.body { padding: 20px; }

div.page div.footer {
    background: var(--surface-alt);
    color: var(--muted);
    padding: 10px 16px;
    font-size: .8rem;
    border-top: 1px solid var(--border);
}

/* ---------- Form controls ---------- */
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font: inherit;
    font-size: .9rem;
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(110, 204, 196, .35);
}

input[type="submit"], button {
    background: var(--teal);
    border: 1px solid var(--teal-dark);
    border-radius: 6px;
    padding: 8px 16px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: background .15s ease;
}
input[type="submit"]:hover, button:hover { background: var(--teal-dark); }

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--teal);
    cursor: pointer;
}

label { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* ---------- Cards / panels ---------- */
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 16px;
    margin-bottom: 20px;
}
.panel > h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: var(--teal);
}
.panel .hint { color: var(--muted); font-size: .85rem; margin: 0 0 12px 0; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

/* ---------- Search grid ---------- */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

table.grid thead th {
    position: sticky;
    top: 0;
    background: var(--teal);
    color: white;
    text-align: left;
    font-weight: 600;
    padding: 10px 10px;
    white-space: nowrap;
    z-index: 1;
}

table.grid tbody td {
    padding: 6px 8px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

table.grid tbody tr:nth-child(even) { background: var(--surface-alt); }
table.grid tbody tr:hover { background: #eef6f5; }
table.grid tbody tr.new-row { background: #fffdf0; }
table.grid .col-check { text-align: center; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .3px;
    background: #e2edeb;
    color: var(--teal-dark);
}
.badge.badge-gm   { background: #d7e9ff; color: #124a8a; }
.badge.badge-sup  { background: #ffe6cc; color: #8a4b12; }
.badge.badge-lead { background: #e5dcff; color: #4b2a8a; }
.badge.badge-none { background: #eceeef; color: var(--muted); }

/* ---------- Flashes / errors ---------- */
ul.flashes, ul.messages { list-style: none; margin: 0 0 16px 0; padding: 0; }

ul.flashes li {
    background: #e6f7f4;
    border: 1px solid #9bd8d0;
    border-left: 4px solid var(--teal);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .9rem;
    margin-bottom: 8px;
}

div.error {
    margin: 12px 0;
    background: #fdeaea;
    border: 1px solid #e6a9a9;
    border-left: 4px solid var(--danger);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .9rem;
    color: var(--danger);
}

div.page strong.warn {
    display: inline-block;
    background: #fff3bf;
    color: #7a5a00;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}

@media (max-width: 640px) {
    div.page { margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
    div.page div.body { padding: 14px; }
}
