/* ============================================================================
   Clarence Portal — shared stylesheet
   Every module page links to THIS file (<link rel="stylesheet" href="/shared/style.css">)
   rather than using inline styles or per-module CSS. That's the whole point:
   one file to reskin later when the real colour scheme lands.

   TO EDIT: this is the placeholder / neutral palette. When Helio provides the
   real colour scheme, only the values in :root below need to change — nothing
   else in this file, and nothing in any module's HTML/JS, should need touching.
   ========================================================================== */

:root {
    /* ---- Brand / structural colours — TO EDIT when colour scheme arrives ---- */
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-border: #dfe3e8;
    --color-text: #1f2933;
    --color-text-muted: #616e7c;
    --color-primary: #3a5a9c;
    --color-primary-hover: #2f4a80;

    /* ---- Status colours — used for badges / dashboard health states ---- */
    --color-good-bg: #e3f6e8;
    --color-good-text: #1e7a3e;
    --color-warn-bg: #fdf1d6;
    --color-warn-text: #93650b;
    --color-bad-bg: #fbe4e4;
    --color-bad-text: #b3261e;
    --color-neutral-bg: #eceff2;
    --color-neutral-text: #4b5563;

    /* ---- Layout ---- */
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --max-width: 1600px;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 16px;
}

a {
    color: var(--color-primary);
}

/* ---------------------------------------------------------------------------
   Page shell — every module page shares this header + main + container pattern
   ------------------------------------------------------------------------- */

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.site-header__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.site-header__title a {
    color: var(--color-text);
    text-decoration: none;
}

.breadcrumb {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.breadcrumb a {
    text-decoration: none;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 4px;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 12px;
}

.page-subtitle {
    color: var(--color-text-muted);
    margin: 0 0 28px;
}

/* ---------------------------------------------------------------------------
   Module hub — home page grid of module cards
   ------------------------------------------------------------------------- */

.module-category {
    margin-bottom: 28px;
}
.category-heading {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.module-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s ease;
}

.module-card:hover {
    border-color: var(--color-primary);
}

.module-card--disabled {
    opacity: 0.55;
    pointer-events: none;
}

.module-card__name {
    font-weight: 600;
    font-size: 1.05rem;
}

.module-card__desc {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    flex-grow: 1;
}

.module-card__status {
    align-self: flex-start;
}

/* ---------------------------------------------------------------------------
   Layout helpers
   ------------------------------------------------------------------------- */

.two-col {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 760px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.panel + .panel {
    margin-top: 16px;
}

/* ---------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text);
}

.field input,
.field select {
    width: 100%;
    max-width: 460px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.field textarea {
    width: 100%;
    max-width: 640px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-field input {
    width: auto;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

button:hover,
.btn:hover {
    background: var(--color-primary-hover);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

button.btn-secondary:hover {
    background: var(--color-bg);
}

/* ---------------------------------------------------------------------------
   Status / badges — colour-coded dashboard building block, reused by every module
   ------------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--good {
    background: var(--color-good-bg);
    color: var(--color-good-text);
}

.badge--warn {
    background: var(--color-warn-bg);
    color: var(--color-warn-text);
}

.badge--bad {
    background: var(--color-bad-bg);
    color: var(--color-bad-text);
}

.badge--neutral {
    background: var(--color-neutral-bg);
    color: var(--color-neutral-text);
}

/* ---------------------------------------------------------------------------
   Data table — used by every module's dashboard
   ------------------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--color-surface);
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody tr:last-child td {
    border-bottom: none;
}

.truncate {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.checked-at {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    white-space: nowrap;
}
.checked-at .checked-at__time {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   Responsive tightening for narrow viewports — tables are the thing most
   likely to overflow, since their content (client names, timestamps) doesn't
   reflow the way prose does.
   ------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .truncate { max-width: 130px; }
    table { font-size: 0.82rem; }
    th, td { padding: 8px 8px; }
}

@media (max-width: 600px) {
    .container { padding: 16px 12px 40px; }
    .site-header__inner { padding: 12px 14px; }
    .truncate { max-width: 100px; }
    th, td { padding: 6px 6px; }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

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

.status-line {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    min-height: 1.2em;
}

.status-line--error {
    color: var(--color-bad-text);
}

.status-line--success {
    color: var(--color-good-text);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
