:root {
    --color-bg: #fafafa;
    --color-text: #1a1a1a;
    --color-muted: #6b7280;
    --color-primary: #0f766e;
    --color-primary-hover: #115e59;
    --color-border: #e5e7eb;
    --color-card: #ffffff;
    --color-danger: #b91c1c;
    --color-success: #15803d;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

    /* M365 admin centre theme — used by _AdminLayout */
    --m-topbar: #1f1f23;
    --m-topbar-text: #ffffff;
    --m-topbar-muted: #c8c8c8;
    --m-canvas-grad: linear-gradient(160deg, #fde4d6 0%, #fae4ee 24%, #f6f4f6 55%, #fafafa 100%);
    --m-card: #ffffff;
    --m-card-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.05);
    --m-card-radius: 8px;
    --m-text: #242424;
    --m-text-muted: #616161;
    --m-divider: #e6e6e6;
    --m-sidebar-bg: #ffffff;
    --m-sidebar-hover: #f3f2f1;
    --m-sidebar-active: #edebe9;
    --m-accent: #d83b01;
    --m-progress: #00b7c3;
    --m-pill-bg: #ffffff;
    --m-pill-border: #d1d1d1;
    --m-status-critical-bg: #fde7e9;
    --m-status-critical-text: #a4262c;
    --m-status-warn-bg: #fff4ce;
    --m-status-warn-text: #8a6500;
    --m-status-need-bg: #ffe9d6;
    --m-status-need-text: #8a4b00;
    --m-status-ok-bg: #dff6dd;
    --m-status-ok-text: #107c10;
}

* { box-sizing: border-box; }

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

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.topbar {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    padding: 0.9rem 0;
}
.topbar-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { display: flex; flex-direction: column; line-height: 1.1; color: var(--color-text); }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 700; font-size: 1.15rem; color: var(--color-primary); }
.brand-sub { font-size: 0.7rem; color: var(--color-muted); letter-spacing: 0.05em; text-transform: uppercase; }

.topnav { display: flex; gap: 1.2rem; align-items: center; }
.topnav a { color: var(--color-text); font-weight: 500; }
.topnav a:hover { color: var(--color-primary); text-decoration: none; }

.inline-form { display: inline; margin: 0; }
.linklike {
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.linklike:hover { color: var(--color-primary); }

main { padding: 2.5rem 0 4rem; min-height: calc(100vh - 200px); }

.hero { max-width: 720px; margin: 2rem 0 3rem; }
.hero h1 { font-size: 2.5rem; margin: 0 0 1rem; line-height: 1.1; }
.hero p { font-size: 1.15rem; color: var(--color-muted); }

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.75rem;
    margin: 1rem 0;
}
.card h2 { margin-top: 0; }

.form { max-width: 480px; }
.form label { display: block; font-weight: 500; margin-top: 1rem; margin-bottom: 0.3rem; }
.form input[type=text],
.form input[type=email],
.form input[type=password] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--color-card);
}
.form input:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }
.form .actions { margin-top: 1.5rem; }

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); text-decoration: none; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.alert-danger { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

.text-muted { color: var(--color-muted); }
.small { font-size: 0.875rem; }

.footer { padding: 1.5rem 0; border-top: 1px solid var(--color-border); color: var(--color-muted); }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat .label { color: var(--color-muted); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }

.validation-summary-errors { color: var(--color-danger); }
.field-validation-error { color: var(--color-danger); font-size: 0.875rem; display: block; margin-top: 0.25rem; }

.admin-body { background: var(--color-bg); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.toolbar h1 { margin: 0; font-size: 1.6rem; }

.table { width: 100%; border-collapse: collapse; background: var(--color-card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 0.65rem 0.9rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.table tbody tr:last-child td { border-bottom: none; }
.table th { background: #f5f5f5; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); font-weight: 600; }
.table tbody tr:hover { background: #fafafa; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-active { background: #dcfce7; color: #14532d; }
.badge-published { background: #cffafe; color: #134e4a; }
.badge-archived { background: #e5e7eb; color: #4b5563; }
.badge-planning { background: #fef3c7; color: #92400e; }
.badge-inproduction { background: #ffedd5; color: #9a3412; }
.badge-complete { background: #dbeafe; color: #1e3a8a; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-row .full { grid-column: 1 / -1; }
.form textarea { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font: inherit; min-height: 90px; }
.form select { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font: inherit; background: var(--color-card); }
.form input[type=number] { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font: inherit; }

.btn-secondary { background: var(--color-card); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f5f5f5; text-decoration: none; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #991b1b; text-decoration: none; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-muted); }
.empty-state h3 { color: var(--color-text); }

.fibre-row { display: grid; grid-template-columns: 2fr 1fr 1.5fr auto auto; gap: 0.5rem; align-items: center; padding: 0.5rem 0; border-top: 1px dashed var(--color-border); }
.fibre-row:first-child { border-top: none; }
.kvp { display: grid; grid-template-columns: 200px 1fr; gap: 0.75rem 1.25rem; }
.kvp .k { color: var(--color-muted); font-size: 0.85rem; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { display: flex; gap: 1rem; padding: 0.75rem 0; border-top: 1px dashed var(--color-border); align-items: start; }
.timeline-item:first-child { border-top: none; }
.timeline-marker { min-width: 110px; text-align: center; padding: 0.3rem 0.5rem; align-self: start; }
.timeline-body { flex: 1; }
.timeline-body p { margin: 0.3rem 0 0; }
.badge-brand { background: #dbeafe; color: #1e3a8a; }
.badge-supplier { background: #f3e8ff; color: #5b21b6; }
.badge-publicrepairshop { background: #fef3c7; color: #92400e; }
.badge-publicowner { background: #dcfce7; color: #14532d; }
.badge-publicrecycler { background: #cffafe; color: #134e4a; }
.badge-manufactured { background: #dbeafe; color: #1e3a8a; }
.badge-sold, .badge-resold, .badge-shipped, .badge-received { background: #fef3c7; color: #92400e; }
.badge-repaired { background: #fae8ff; color: #6b21a8; }
.badge-recycled, .badge-disposed, .badge-inspected { background: #d1fae5; color: #065f46; }
.badge-auditor { background: #fae8ff; color: #6b21a8; }
.badge-repair { background: #fef3c7; color: #92400e; }

.tier-badge {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.3;
    vertical-align: middle;
    cursor: help;
}
.tier-m { background: #fee2e2; color: #991b1b; }
.tier-r { background: #fef3c7; color: #92400e; }
.tier-v { background: #e0f2fe; color: #075985; }

.retention-badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #155e75;
    font-size: 0.85rem;
}
.retention-badge.expired { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ============================================================
   Microsoft 365 admin centre — themed shell for /Admin pages.
   ============================================================ */

body.m-body {
    margin: 0;
    background: #f5f5f5;
    color: var(--m-text);
    font-family: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
}

.m-topbar {
    height: 48px;
    background: var(--m-topbar);
    color: var(--m-topbar-text);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.m-topbar-waffle {
    background: none;
    border: none;
    color: var(--m-topbar-text);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.m-topbar-waffle:hover { background: rgba(255,255,255,0.08); }
.m-topbar-title {
    color: var(--m-topbar-text);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}
.m-topbar-title:hover { text-decoration: none; color: var(--m-topbar-text); }
.m-topbar-search {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}
.m-topbar-search input {
    width: 100%;
    height: 32px;
    padding: 0 14px 0 38px;
    background: rgba(255,255,255,0.08);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--m-topbar-text);
    font: inherit;
    outline: none;
}
.m-topbar-search input::placeholder { color: var(--m-topbar-muted); }
.m-topbar-search input:focus { background: #ffffff; color: var(--m-text); }
.m-topbar-search input:focus::placeholder { color: var(--m-text-muted); }
.m-topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.85;
}
.m-topbar-right { display: flex; align-items: center; gap: 4px; }
.m-topbar-org {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    color: var(--m-topbar-text);
    font-size: 13px;
    border-radius: 4px;
}
.m-topbar-org:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: var(--m-topbar-text); }
.m-iconbtn {
    background: none;
    border: none;
    color: var(--m-topbar-text);
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.m-iconbtn:hover { background: rgba(255,255,255,0.08); }

.m-shell { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 48px); }

.m-sidebar {
    background: var(--m-sidebar-bg);
    border-right: 1px solid var(--m-divider);
    padding: 8px 0;
    overflow-y: auto;
}
.m-sidebar-hamburger {
    background: none;
    border: none;
    color: var(--m-text);
    padding: 10px 16px;
    cursor: pointer;
    width: 44px;
    border-radius: 4px;
    margin: 4px 8px;
}
.m-sidebar-hamburger:hover { background: var(--m-sidebar-hover); }
.m-sidebar-nav { list-style: none; padding: 0; margin: 0; }
.m-sidebar-nav li { margin: 0; }
.m-sidebar-nav a, .m-sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 18px;
    color: var(--m-text);
    font-size: 14px;
    border-left: 2px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
    font: inherit;
}
.m-sidebar-nav a:hover, .m-sidebar-group-toggle:hover { background: var(--m-sidebar-hover); text-decoration: none; color: var(--m-text); }
.m-sidebar-nav a.is-active { background: var(--m-sidebar-active); border-left-color: var(--m-accent); font-weight: 600; }
.m-sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; color: #424242; }
.m-sidebar-nav a.is-active .m-sidebar-icon { color: var(--m-accent); }
.m-sidebar-chevron { margin-left: auto; transition: transform 0.15s; }
.m-sidebar-group[open] .m-sidebar-chevron { transform: rotate(180deg); }
.m-sidebar-sub { list-style: none; padding: 0; margin: 0; }
.m-sidebar-sub a { padding-left: 50px; font-size: 13.5px; }

.m-canvas {
    background: var(--m-canvas-grad);
    min-height: calc(100vh - 48px);
    padding: 32px 48px 64px;
    overflow-x: hidden;
}
.m-canvas-inner { max-width: 1400px; margin: 0 auto; }

.m-page-title {
    font-size: 30px;
    font-weight: 600;
    margin: 16px 0 8px;
    text-align: center;
    color: var(--m-text);
}
.m-page-title.left { text-align: left; }

.m-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--m-text);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.m-section-label .m-sidebar-chevron { margin-left: 0; }

.m-card {
    background: var(--m-card);
    border-radius: var(--m-card-radius);
    box-shadow: var(--m-card-shadow);
    padding: 20px;
}
.m-card-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.m-card-header { font-size: 14px; font-weight: 600; color: var(--m-text); margin-bottom: 12px; }
.m-card-metric-label { font-size: 12px; color: var(--m-text-muted); margin-bottom: 4px; }
.m-card-metric-value { font-size: 32px; font-weight: 600; line-height: 1.1; color: var(--m-text); }
.m-card-metric-row { display: flex; gap: 20px; margin: 8px 0 14px; }
.m-card-progress-label { font-size: 12px; color: var(--m-text-muted); margin: 8px 0 4px; display: flex; justify-content: space-between; }
.m-card-progress-bar {
    height: 4px;
    background: #edebe9;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
.m-card-progress-fill { height: 100%; background: var(--m-progress); border-radius: 2px; }
.m-card-action {
    display: inline-block;
    background: #ffffff;
    border: 1px solid #8a8886;
    color: var(--m-text);
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}
.m-card-action:hover { background: #f3f2f1; text-decoration: none; color: var(--m-text); }

.m-pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; align-items: center; }
.m-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background: var(--m-pill-bg);
    border: 1px solid var(--m-pill-border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--m-text);
    text-decoration: none;
    cursor: pointer;
}
.m-pill:hover { background: #f3f2f1; text-decoration: none; color: var(--m-text); }
.m-pill.is-active { background: var(--m-text); color: #ffffff; border-color: var(--m-text); }

.m-status-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.m-status-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}
.m-status-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--m-text);
}
.m-status-card-sub { font-size: 12px; color: var(--m-text-muted); }
.m-status-card-headline { font-size: 18px; font-weight: 600; margin: 6px 0 14px; }

.m-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.m-status-pill.critical { background: var(--m-status-critical-bg); color: var(--m-status-critical-text); }
.m-status-pill.warn { background: var(--m-status-warn-bg); color: var(--m-status-warn-text); }
.m-status-pill.need { background: var(--m-status-need-bg); color: var(--m-status-need-text); }
.m-status-pill.ok { background: var(--m-status-ok-bg); color: var(--m-status-ok-text); }

.m-status-list { list-style: none; padding: 0; margin: 0; }
.m-status-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--m-divider);
    font-size: 13px;
    color: var(--m-text);
}
.m-status-list li:first-child { border-top: none; }
.m-status-list .meta { font-size: 12px; color: var(--m-text-muted); }

/* Toggle the "new dashboard" pill at top */
.m-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.m-toggle {
    position: relative;
    width: 36px;
    height: 18px;
    background: var(--m-text);
    border-radius: 999px;
    flex-shrink: 0;
}
.m-toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
}
.m-toggle-label { font-size: 13px; color: var(--m-text); }

/* Backwards-compatibility: keep existing admin pages working inside the new shell.
   Old pages use .toolbar / .card / .table — we just place them inside .m-canvas. */
.m-canvas .toolbar h1 { font-size: 22px; }
.m-canvas .card { box-shadow: var(--m-card-shadow); border: none; border-radius: var(--m-card-radius); }

/* Old admin-shell grid used by older pages — kept for fallback if anything still references it. */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; padding: 2rem 0 3rem; align-items: start; }
.admin-sidebar nav ul { list-style: none; padding: 0; margin: 0; }
.admin-sidebar nav ul li { margin: 0.2rem 0; }
.admin-sidebar nav ul li a { display: block; padding: 0.45rem 0.7rem; border-radius: var(--radius); color: var(--color-text); font-weight: 500; }
.admin-sidebar nav ul li a:hover { background: var(--color-card); text-decoration: none; }
.admin-sidebar nav ul.muted li { color: var(--color-muted); padding: 0.35rem 0.7rem; font-size: 0.9rem; }
.admin-sidebar h4 { margin: 0; font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; }
.admin-main { min-width: 0; }
