/* ==========================================================================
   Brevv ERP — shell styling.

   Values are taken from the LMS admin shell (templates/admin_base.html) so
   the two products read as one: same blue, same greys, same elevation, and
   the same sidebar treatment — a rounded pill with a 4px bar on the active
   item. Anyone moving between the apps should not notice a seam.
   ========================================================================== */

:root {
    --md-primary:      #008cff;
    --md-primary-dark: #0072d6;
    --md-secondary:    #dc004e;
    --md-background:   #f5f5f5;
    --md-surface:      #ffffff;
    --md-error:        #f44336;
    --md-success:      #4caf50;
    --md-warning:      #ff9800;
    --md-info:         #008cff;

    --text-primary:   rgba(0, 0, 0, 0.87);
    --text-secondary: rgba(0, 0, 0, 0.60);
    --text-disabled:  rgba(0, 0, 0, 0.38);
    --divider:        rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--md-background);
    color: var(--text-primary);
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Material elevation, matching the LMS */
.elevation-1 { box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.elevation-2 { box-shadow: 0 3px 6px rgba(0,0,0,0.10); }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.erp-shell { display: flex; min-height: 100vh; }

.erp-sidebar {
    width: 256px;
    flex: none;
    background: var(--md-surface);
    display: flex;
    flex-direction: column;
    box-shadow: 0 3px 6px rgba(0,0,0,0.10);
}

.erp-brand {
    padding: 18px 20px;
    border-bottom: 1px solid var(--divider);
}
.erp-brand-mark {
    font-size: 20px;
    font-weight: 700;
    color: var(--md-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-decoration: none;
    display: block;
}
.erp-brand-sub {
    font-size: 9px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-top: 3px;
}

.erp-nav { flex: 1; padding: 16px 0 16px 12px; overflow-y: auto; }
.erp-nav-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0 16px;
    margin-bottom: 8px;
}

/* Same geometry as the LMS .nav-item */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 0 24px 24px 0;
    margin-right: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item:hover  { background-color: rgba(0, 140, 255, 0.08); }
.nav-item.active { background-color: rgba(0, 140, 255, 0.12); color: var(--md-primary); }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background-color: var(--md-primary);
    border-radius: 0 4px 4px 0;
}
.nav-item .material-icons-outlined { font-size: 20px; }

/* Sections exist here from the start — the ERP has more areas than the LMS
   sidebar was built for, and a flat list of a dozen items scans badly. */
.erp-nav-section { margin-top: 20px; }

/* --------------------------------------------------------------------------
   Main column
   -------------------------------------------------------------------------- */
.erp-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.erp-topbar {
    background: var(--md-surface);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.erp-topbar h1 { font-size: 18px; font-weight: 500; margin: 0; }

.erp-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}
.erp-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--md-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}

.erp-content { padding: 24px; flex: 1; }

/* --------------------------------------------------------------------------
   Cards / surfaces
   -------------------------------------------------------------------------- */
.card {
    background: var(--md-surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.card + .card { margin-top: 16px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.stat {
    background: var(--md-surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 28px;
    font-weight: 500;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-value.muted { color: var(--text-disabled); font-weight: 400; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}
.empty-state .material-icons-outlined {
    font-size: 48px;
    color: #d1d5db;
    display: block;
    margin: 0 auto 12px;
}

/* --------------------------------------------------------------------------
   Buttons / forms
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--md-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 140, 255, 0.25);
}
.btn-primary:hover  { background: var(--md-primary-dark); box-shadow: 0 4px 10px rgba(0, 140, 255, 0.32); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
.btn-text { background: none; color: var(--md-primary); }
.btn-text:hover { background: rgba(0, 140, 255, 0.06); }

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(0, 140, 255, 0.12);
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}
.alert-error { background: rgba(244, 67, 54, 0.08); color: #c62828; border-left: 3px solid var(--md-error); }

/* --------------------------------------------------------------------------
   Sign-in page
   -------------------------------------------------------------------------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(168deg, #f8fbff 6%, #f0f7ff 37%, #e0efff 68%, #d0e5ff 94%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 12px 40px rgba(15, 29, 46, 0.12);
}
.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #0f172a;
}
.login-card .sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 26px;
}
.login-brand {
    font-size: 22px;
    font-weight: 700;
    color: var(--md-primary);
    letter-spacing: -0.02em;
}
.login-brand span {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

@media (max-width: 760px) {
    .erp-sidebar { display: none; }
    .erp-content { padding: 16px; }
}

/* --------------------------------------------------------------------------
   Data tables — used across the finance screens
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
table.data th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 10px 14px;
    border-bottom: 1px solid var(--divider);
    white-space: nowrap;
}
table.data td {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(0, 140, 255, 0.03); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-secondary); }

/* Status is carried by shape and colour, so it reads without being read. */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 11px;
    white-space: nowrap;
}
.badge-draft     { background: #eceff1; color: #546e7a; }
.badge-issued    { background: rgba(0,140,255,0.12);  color: #0072d6; }
.badge-part_paid { background: rgba(255,152,0,0.14);  color: #b26500; }
.badge-paid      { background: rgba(76,175,80,0.14);  color: #2e7d32; }
.badge-cancelled { background: #f5f5f5; color: #9e9e9e; }
.badge-pending   { background: #eceff1; color: #546e7a; }
.badge-waived    { background: #f5f5f5; color: #9e9e9e; }
.badge-overdue   { background: rgba(244,67,54,0.12);  color: #c62828; }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.inline-form input, .inline-form select { height: 40px; }
.field select {
    width: 100%; height: 44px; padding: 10px 14px; font-size: 15px;
    font-family: inherit; background: #fff;
    border: 1px solid rgba(0,0,0,0.23); border-radius: 6px; outline: none;
}
.field textarea {
    width: 100%; padding: 10px 14px; font-size: 15px; font-family: inherit;
    border: 1px solid rgba(0,0,0,0.23); border-radius: 6px; outline: none; resize: vertical;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
a.plain { color: var(--md-primary); text-decoration: none; font-weight: 500; }
a.plain:hover { text-decoration: underline; }

@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }
