/* ============================================================
   Martial Arts Club Manager — Frontend stylesheet
   Palette: white & light-gray surfaces with a slate-blue accent.
   Status colours intentionally neutralised: differentiation
   comes from icons + labels + dot indicators, not from hue.
   ============================================================ */

/* Defensive overrides: some themes (OceanWP, Astra, etc.) apply
   underline-on-hover or other anchor styling globally. Inside the
   dashboard we never want those defaults to bleed through. */
.macm-app a,
.macm-app a:link,
.macm-app a:visited,
.macm-app a:hover,
.macm-app a:focus,
.macm-app a:active {
    text-decoration: none !important;
    box-shadow: none !important;
}
/* Allow underline in genuine prose blocks (notes, descriptions) — those
   classes opt in explicitly. */
.macm-app .macm-prose a,
.macm-app .macm-link-underline {
    text-decoration: underline !important;
}

:root {
    /* ---- Surfaces ---- */
    --macm-bg:           #f7f8fa;   /* page background */
    --macm-surface:      #ffffff;   /* cards, panels */
    --macm-surface-2:    #f1f3f5;   /* recessed / hover */
    --macm-sidebar:      #f1f3f5;   /* light sidebar */
    --macm-sidebar-text: #374151;

    /* ---- Text ---- */
    --macm-text:    #1f2937;
    --macm-muted:   #6b7280;
    --macm-faint:   #9ca3af;

    /* ---- Borders ---- */
    --macm-border:        #e5e7eb;
    --macm-border-strong: #d1d5db;

    /* ---- Accent (slate blue) ---- */
    --macm-primary:        #475569;
    --macm-primary-hover:  #334155;
    --macm-primary-soft:   #f1f5f9;
    --macm-primary-text:   #ffffff;
    --macm-primary-on-soft:#334155;

    /* ---- Status (neutral grays) ---- */
    --macm-status-bg:    #f1f3f5;
    --macm-status-text:  #374151;
    --macm-status-strong:#1f2937;

    /* ---- Shape ---- */
    --macm-radius:    8px;
    --macm-radius-lg: 12px;
    --macm-shadow:    0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ============================================================
   Layout shell
   ============================================================ */
.macm-app {
    display: flex;
    gap: 0;
    max-width: 1300px;
    margin: 20px auto;
    background: var(--macm-bg);
    border-radius: var(--macm-radius-lg);
    border: 1px solid var(--macm-border);
    min-height: 720px;
    color: var(--macm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
}

.macm-sidebar {
    width: 240px;
    background: var(--macm-sidebar);
    color: var(--macm-sidebar-text);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--macm-border);
}

.macm-brand {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 4px 6px 16px;
    border-bottom: 1px solid var(--macm-border);
    margin-bottom: 14px;
}
.macm-brand-logo {
    width: 36px; height: 36px;
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.macm-brand-text strong { display: block; font-size: 14px; font-weight: 600; color: var(--macm-text); }
.macm-brand-text span  { font-size: 10px; color: var(--macm-faint); text-transform: uppercase; letter-spacing: 0.6px; }

.macm-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.macm-nav-item,
.macm-nav-item:link,
.macm-nav-item:visited,
.macm-nav-item:hover,
.macm-nav-item:focus,
.macm-nav-item:active {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--macm-radius);
    font-size: 13px;
    color: var(--macm-sidebar-text);
    text-decoration: none !important;
    box-shadow: none !important;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.macm-nav-item:hover { background: var(--macm-surface); color: var(--macm-text); }
.macm-nav-item.active {
    background: var(--macm-primary);
    color: var(--macm-primary-text);
    font-weight: 500;
}
.macm-nav-item .ico { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.macm-nav-item .macm-icon-img { width: 18px !important; height: 18px !important; }
.macm-nav-label { flex: 1; text-decoration: none !important; }
.macm-nav-divider { border: 0; border-top: 1px solid var(--macm-border); margin: 8px 6px; }

.macm-sidebar-footer { padding-top: 12px; border-top: 1px solid var(--macm-border); }

.macm-main {
    flex: 1;
    padding: 24px;
    background: var(--macm-bg);
    min-width: 0;
    overflow-x: hidden;
}

/* ============================================================
   Top bar
   ============================================================ */
.macm-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 14px;
}
.macm-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.macm-topbar h1 { margin: 0 0 2px; font-size: 22px; font-weight: 600; color: var(--macm-text); }
.macm-sub { margin: 0; color: var(--macm-muted); font-size: 13px; }
.macm-topbar-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.macm-topbar-avatar { cursor: default; }

.macm-live {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--macm-muted);
    padding: 4px 10px; background: var(--macm-surface);
    border: 1px solid var(--macm-border); border-radius: 999px;
}
.macm-pulse {
    width: 8px; height: 8px; border-radius: 50%;
    background: #dc2626;
    animation: macm-pulse-blink 1s ease-in-out infinite;
}
@keyframes macm-pulse-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
    50%      { opacity: 0.3; box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.macm-live-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #dc2626;
    display: inline-block;
    animation: macm-pulse-blink 1s ease-in-out infinite;
    flex-shrink: 0;
}

/* ============================================================
   Avatars
   ============================================================ */
.macm-avatar {
    width: 70px; height: 70px; border-radius: 50%;
    background: var(--macm-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 600;
    overflow: hidden; flex-shrink: 0;
}
.macm-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.macm-avatar-sm { width: 40px; height: 40px; font-size: 15px; }
.macm-avatar-lg { width: 88px; height: 88px; font-size: 36px; }

/* ============================================================
   Cards / sections
   ============================================================ */
.macm-card {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--macm-shadow);
}
.macm-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 10px;
    flex-wrap: wrap;
}
.macm-card-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--macm-text); }
.macm-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.macm-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

/* Stats cards */
.macm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.macm-stat {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    padding: 14px 16px;
    display: flex; gap: 12px; align-items: center;
    box-shadow: var(--macm-shadow);
}
.macm-stat-icon {
    width: 38px; height: 38px;
    border-radius: var(--macm-radius);
    background: var(--macm-surface-2);
    color: var(--macm-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.macm-stat-num { font-size: 22px; font-weight: 600; line-height: 1; color: var(--macm-text); }
.macm-stat-label { font-size: 11px; color: var(--macm-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ============================================================
   Buttons
   ============================================================ */
.macm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--macm-radius);
    border: 1px solid var(--macm-border);
    background: var(--macm-surface);
    color: var(--macm-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
    font-family: inherit;
}
.macm-btn:hover { background: var(--macm-surface-2); border-color: var(--macm-border-strong); }
.macm-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.macm-btn-sm { padding: 6px 10px; font-size: 12px; }
.macm-btn-primary {
    background: var(--macm-primary);
    color: var(--macm-primary-text);
    border-color: var(--macm-primary);
}
.macm-btn-primary:hover {
    background: var(--macm-primary-hover);
    border-color: var(--macm-primary-hover);
}
.macm-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--macm-muted);
}
.macm-btn-ghost:hover { background: var(--macm-surface-2); color: var(--macm-text); }
.macm-btn-danger {
    background: var(--macm-surface);
    color: var(--macm-text);
    border-color: var(--macm-border-strong);
}
.macm-btn-danger:hover {
    background: var(--macm-surface-2);
    color: var(--macm-text);
    border-color: var(--macm-border-strong);
}

.macm-btn-spinner { display: none; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: macm-spin 0.6s linear infinite; }
.macm-btn.loading .macm-btn-text { display: none; }
.macm-btn.loading .macm-btn-spinner { display: inline-block; }
@keyframes macm-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Forms
   ============================================================ */
.macm-field { display: flex; flex-direction: column; gap: 4px; }
.macm-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--macm-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.macm-field input[type=text],
.macm-field input[type=email],
.macm-field input[type=tel],
.macm-field input[type=url],
.macm-field input[type=password],
.macm-field input[type=number],
.macm-field input[type=date],
.macm-field select,
.macm-field textarea,
input.regular-text,
.macm-stack input,
.macm-stack select,
.macm-stack textarea {
    padding: 9px 11px;
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    font-size: 14px;
    background: var(--macm-surface);
    color: var(--macm-text);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
.macm-field select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8L0 0h12z'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.macm-field textarea { resize: vertical; min-height: 70px; }

/* Password input with visibility toggle (eye icon) */
.macm-pw-wrap { position: relative; }
.macm-pw-wrap input[type=password],
.macm-pw-wrap input[type=text] {
    width: 100%;
    padding-right: 44px; /* room for the eye button */
}
.macm-pw-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--macm-muted);
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
}
.macm-pw-toggle:hover { background: var(--macm-surface-2); color: var(--macm-text); }
.macm-pw-toggle .macm-pw-icon { display: inline-block; font-style: normal; }

.macm-field input:focus,
.macm-field select:focus,
.macm-field textarea:focus {
    outline: none;
    border-color: var(--macm-primary);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.macm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.macm-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.macm-form-grid .macm-field-full { grid-column: 1 / -1; }
.macm-form-grid .macm-section-title,
.macm-section-title {
    grid-column: 1 / -1;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--macm-muted);
    letter-spacing: 0.5px;
    margin: 12px 0 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--macm-border);
    font-weight: 600;
}
.macm-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
    flex-wrap: wrap;
    grid-column: 1 / -1;
}
.macm-form-msg { font-size: 12px; padding: 6px 10px; border-radius: 6px; display: none; }
.macm-form-msg.success { display: inline-block; background: var(--macm-surface-2); color: var(--macm-text); border: 1px solid var(--macm-border); }
.macm-form-msg.error   { display: inline-block; background: var(--macm-surface-2); color: var(--macm-text); border: 1px solid var(--macm-border-strong); }
.macm-form-msg.info    { display: inline-block; background: var(--macm-surface-2); color: var(--macm-muted); }

.macm-stack { display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 720px) { .macm-form-grid, .macm-form-grid-2 { grid-template-columns: 1fr; } }

/* ============================================================
   Pills, badges, status (NEUTRAL — no green/amber/red hues)
   ============================================================ */
.macm-pill,
.macm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--macm-status-bg);
    color: var(--macm-status-text);
    border: 1px solid var(--macm-border);
    line-height: 1.5;
}

/* Role badges — kept neutral; differ by border weight + dot */
.macm-badge-owner_admin::before,
.macm-badge-co_admin::before,
.macm-badge-instructor::before,
.macm-badge-assistant::before,
.macm-badge-staff::before,
.macm-badge-member::before,
.macm-badge-parent::before,
.macm-badge-pending::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--macm-status-strong);
    display: inline-block;
}
.macm-badge-owner_admin::before { background: #1f2937; }
.macm-badge-co_admin::before    { background: #374151; }
.macm-badge-instructor::before  { background: #4b5563; }
.macm-badge-assistant::before   { background: #6b7280; }
.macm-badge-staff::before       { background: #9ca3af; }
.macm-badge-member::before      { background: #d1d5db; }
.macm-badge-parent::before      { background: #d1d5db; border: 1px solid #9ca3af; width: 5px; height: 5px; }
.macm-badge-pending::before     { background: transparent; border: 1px dashed #9ca3af; width: 8px; height: 8px; }
.macm-badge-pending { color: var(--macm-muted); }

/* Status pills — same neutral look, differentiated by icon prefix */
.macm-record-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--macm-status-bg);
    color: var(--macm-status-text);
    border: 1px solid var(--macm-border);
}

/* ============================================================
   Tables
   ============================================================ */
.macm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.macm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.macm-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--macm-muted);
    background: var(--macm-surface-2);
    border-bottom: 1px solid var(--macm-border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    /* Keep column headers visible while scrolling the table body inside
       a height-capped .macm-table-wrap */
    position: sticky;
    top: 0;
    z-index: 2;
}
.macm-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--macm-border);
    vertical-align: middle;
}
.macm-table tbody tr:hover td { background: var(--macm-surface-2); }
.macm-table tbody tr:last-child td { border-bottom: 0; }

/* ============================================================
   Activity / Records lists
   ============================================================ */
.macm-activity-feed { display: flex; flex-direction: column; gap: 6px; }

/* ============================================================
   UNIFIED SCROLL CAP — every list-bearing pane on every tab
   ============================================================
   Goal: the dashboard chrome (sidebar, topbar, stats) never moves;
   any list that could grow long scrolls inside its own container.
   Card heads stay pinned outside the scroll area, so titles and
   action buttons remain visible while users scroll the list. */
#macm-activity-full,
#macm-archive-list,
#macm-activity-feed,
.macm-module-body,
.macm-card .macm-table-wrap,
.macm-cert-list,
.macm-scroll-pane {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--macm-border) transparent;
}
/* Per-pane height caps */
#macm-activity-full,
#macm-archive-list             { max-height: 65vh; }
#macm-activity-feed            { max-height: 420px; }
.macm-module-body              { max-height: 60vh; min-height: 320px; }
.macm-card .macm-table-wrap    { max-height: 60vh; }
.macm-cert-list                { max-height: 60vh; }

/* WebKit scrollbar styling — shared */
#macm-activity-full::-webkit-scrollbar,
#macm-archive-list::-webkit-scrollbar,
#macm-activity-feed::-webkit-scrollbar,
.macm-module-body::-webkit-scrollbar,
.macm-card .macm-table-wrap::-webkit-scrollbar,
.macm-cert-list::-webkit-scrollbar,
.macm-scroll-pane::-webkit-scrollbar { width: 8px; }

#macm-activity-full::-webkit-scrollbar-track,
#macm-archive-list::-webkit-scrollbar-track,
#macm-activity-feed::-webkit-scrollbar-track,
.macm-module-body::-webkit-scrollbar-track,
.macm-card .macm-table-wrap::-webkit-scrollbar-track,
.macm-cert-list::-webkit-scrollbar-track,
.macm-scroll-pane::-webkit-scrollbar-track { background: transparent; }

#macm-activity-full::-webkit-scrollbar-thumb,
#macm-archive-list::-webkit-scrollbar-thumb,
#macm-activity-feed::-webkit-scrollbar-thumb,
.macm-module-body::-webkit-scrollbar-thumb,
.macm-card .macm-table-wrap::-webkit-scrollbar-thumb,
.macm-cert-list::-webkit-scrollbar-thumb,
.macm-scroll-pane::-webkit-scrollbar-thumb {
    background: var(--macm-border);
    border-radius: 4px;
}
#macm-activity-full::-webkit-scrollbar-thumb:hover,
#macm-archive-list::-webkit-scrollbar-thumb:hover,
#macm-activity-feed::-webkit-scrollbar-thumb:hover,
.macm-module-body::-webkit-scrollbar-thumb:hover,
.macm-card .macm-table-wrap::-webkit-scrollbar-thumb:hover,
.macm-cert-list::-webkit-scrollbar-thumb:hover,
.macm-scroll-pane::-webkit-scrollbar-thumb:hover { background: var(--macm-muted); }

/* Mobile: a touch more vertical room because narrower lists are denser */
@media (max-width: 880px) {
    #macm-activity-full,
    #macm-archive-list             { max-height: 70vh; }
    #macm-activity-feed            { max-height: 360px; }
    .macm-module-body              { max-height: 55vh; min-height: 240px; }
    .macm-card .macm-table-wrap    { max-height: 55vh; }
    .macm-cert-list                { max-height: 55vh; }
}
.macm-act-item {
    display: flex; gap: 10px;
    padding: 10px;
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
}
.macm-act-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--macm-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.macm-act-body { flex: 1; min-width: 0; }
.macm-act-line { font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.macm-act-action {
    background: var(--macm-surface-2);
    color: var(--macm-muted);
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.macm-act-module { color: var(--macm-faint); font-size: 11px; }
.macm-act-desc { font-size: 13px; color: var(--macm-text); margin-top: 2px; }
.macm-act-time { font-size: 11px; color: var(--macm-faint); margin-top: 2px; font-variant-numeric: tabular-nums; }

.macm-record-list { display: flex; flex-direction: column; gap: 8px; }
.macm-record {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
}
.macm-record-main { flex: 1; min-width: 0; }
.macm-record-title { font-size: 14px; font-weight: 500; color: var(--macm-text); margin-bottom: 3px; }
.macm-record-meta { font-size: 12px; color: var(--macm-muted); }
.macm-record-desc { font-size: 13px; color: var(--macm-text); margin-top: 4px; }
.macm-record-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ============================================================
   Modal
   ============================================================ */
.macm-modal {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; padding: 16px;
}
.macm-modal[hidden] { display: none; }
.macm-modal-card {
    background: var(--macm-surface);
    border-radius: var(--macm-radius-lg);
    max-width: 560px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}
.macm-modal-large { max-width: 760px; }
.macm-modal-x, .macm-form-close, .macm-modal-close {
    position: absolute; top: 12px; right: 14px;
    background: transparent; border: 0;
    font-size: 22px; color: var(--macm-faint);
    cursor: pointer; padding: 4px 8px; line-height: 1;
}
.macm-modal-x:hover, .macm-form-close:hover, .macm-modal-close:hover { color: var(--macm-text); }
.macm-form-title, #macm-form-title {
    margin: 0 0 16px;
    padding-right: 30px;
    font-size: 18px;
    font-weight: 600;
}
.macm-form-modal { padding: 22px; }
.macm-form-body { padding-top: 4px; }

/* ============================================================
   Compliance / Certificates
   ============================================================ */
.macm-cert-list { display: flex; flex-direction: column; gap: 0; }
.macm-cert-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--macm-border);
}
.macm-cert-row:last-child { border-bottom: 0; }
.macm-cert-label { font-size: 13px; font-weight: 500; color: var(--macm-text); }
.macm-cert-meta { display: flex; gap: 10px; align-items: center; }
.macm-cert-date { font-size: 12px; color: var(--macm-muted); font-variant-numeric: tabular-nums; }

/* ============================================================
   Auth / login page
   ============================================================ */
.macm-auth-wrap {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--macm-bg);
    padding: 30px 16px;
}
.macm-auth-card {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius-lg);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    width: 100%; max-width: 420px;
    padding: 36px 32px;
}
.macm-auth-brand { text-align: center; margin-bottom: 24px; }
.macm-auth-logo {
    width: 64px; height: 64px;
    background: var(--macm-primary);
    border-radius: var(--macm-radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 30px; color: #fff;
    margin-bottom: 12px;
}
.macm-auth-brand h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--macm-text); }
.macm-auth-brand p  { margin: 0; color: var(--macm-muted); font-size: 13px; }

.macm-auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--macm-border);
}
.macm-tab {
    flex: 1;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--macm-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    font-family: inherit;
}
.macm-tab.active { color: var(--macm-primary); border-bottom-color: var(--macm-primary); }

.macm-auth-form { display: none; flex-direction: column; gap: 14px; }
.macm-auth-form.active { display: flex; }
.macm-auth-form .macm-btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ============================================================
   Profile page
   ============================================================ */
.macm-profile { display: flex; gap: 18px; align-items: center; }
.macm-profile-info h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; color: var(--macm-text); }
.macm-profile-info p  { margin: 2px 0; color: var(--macm-muted); font-size: 13px; }

.macm-quals { display: flex; flex-direction: column; gap: 8px; }
.macm-qual-item {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 12px 14px;
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
}
.macm-qual-meta { font-size: 12px; color: var(--macm-muted); margin-top: 3px; }
.macm-qual-desc { font-size: 13px; color: var(--macm-muted); margin-top: 4px; }

/* ============================================================
   Empty / loading states
   ============================================================ */
.macm-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--macm-muted);
    background: var(--macm-surface-2);
    border-radius: var(--macm-radius);
    font-size: 13px;
}
.macm-empty-inline { color: var(--macm-muted); font-size: 13px; }
.macm-loading { padding: 20px; text-align: center; color: var(--macm-muted); font-size: 13px; }
.macm-muted { color: var(--macm-muted); }

/* ============================================================
   Views (hide/show pages)
   ============================================================ */
.macm-view { display: none; }
.macm-view.active { display: block; }

/* ============================================================
   Stretch module views to fill the dashboard height.

   The sidebar is naturally taller than a single-card module pane
   (Invoice, Work Record, Lesson Plan, etc.), leaving empty space
   below. By chaining flex on .macm-main → active view → card →
   .macm-module-body, the body grows to absorb that space and the
   pane visually matches the sidebar.

   :has() scopes this so it ONLY applies when the active view
   actually contains a .macm-module-body — the Overview pane (which
   has many stacked cards and no module body) is left alone.
   ============================================================ */
.macm-main { display: flex; flex-direction: column; }
.macm-view.active:has(.macm-module-body) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.macm-view.active:has(.macm-module-body) > .macm-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    min-height: 0;
}
.macm-view.active:has(.macm-module-body) .macm-module-body {
    flex: 1;
    max-height: none;          /* let it grow with the pane */
    min-height: 320px;         /* sensible floor on small content */
}

/* ============================================================
   Editable headings
   ============================================================ */
.macm-editable-heading {
    display: flex; gap: 8px; align-items: center;
    margin: 0;
    font-size: 16px; font-weight: 600;
}
.macm-h-icon { font-size: 18px; }
.macm-heading-input {
    border: 1px solid var(--macm-primary) !important;
    padding: 4px 8px !important;
    font-size: 16px !important;
    border-radius: 6px !important;
}
.macm-pencil {
    background: transparent; border: 0;
    color: var(--macm-faint); cursor: pointer; padding: 2px 4px; font-size: 13px;
}
.macm-pencil:hover { color: var(--macm-text); }
.macm-chev {
    background: transparent; border: 0;
    color: var(--macm-faint); cursor: pointer; padding: 2px 4px; font-size: 16px;
}

/* ============================================================
   Live update bar (lesson plan, activity)
   ============================================================ */
.macm-live-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--macm-surface-2);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    font-size: 12px;
    color: var(--macm-muted);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.macm-live-refresh { background: transparent; border: 0; color: var(--macm-primary); cursor: pointer; font-size: 12px; font-weight: 500; padding: 0; }
.macm-live-time { font-variant-numeric: tabular-nums; color: var(--macm-faint); }

/* ============================================================
   Lesson Plan specific
   ============================================================ */
.macm-lesson-current {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius-lg);
    padding: 18px 20px;
    margin-bottom: 14px;
}
.macm-lesson-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--macm-muted); margin-bottom: 6px; font-weight: 600; }
.macm-lesson-title, .macm-lesson-current .title { font-size: 20px; font-weight: 600; margin: 0 0 6px; color: var(--macm-text); }
.macm-lesson-date { font-size: 13px; color: var(--macm-muted); }
.macm-lesson-meta { font-size: 13px; color: var(--macm-muted); margin-top: 6px; }
.macm-lesson-notes { font-size: 14px; color: var(--macm-text); margin-top: 10px; white-space: pre-line; }

.macm-lesson-past { margin-top: 14px; }
.macm-lesson-past-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; cursor: pointer; }
.macm-lesson-past-list { display: flex; flex-direction: column; gap: 4px; }
.macm-lesson-past-row {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    padding: 10px 12px;
    cursor: pointer;
}
.macm-lesson-past-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.macm-past-date { font-size: 12px; color: var(--macm-muted); font-variant-numeric: tabular-nums; }
.macm-past-title { font-size: 13px; font-weight: 500; flex: 1; }
.macm-past-who { font-size: 12px; color: var(--macm-faint); }
.macm-past-chev { font-size: 14px; color: var(--macm-faint); }
.macm-past-notes { display: none; padding: 8px 0 4px; font-size: 13px; color: var(--macm-muted); white-space: pre-line; }
.macm-lesson-past-row.open .macm-past-notes { display: block; }

/* ============================================================
   Archive
   ============================================================ */
.macm-archive-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.macm-archive-filters select { padding: 6px 10px; border: 1px solid var(--macm-border); border-radius: 6px; font-size: 13px; background: var(--macm-surface); }
.macm-archive-stats { font-size: 13px; color: var(--macm-muted); margin-bottom: 14px; padding: 8px 12px; background: var(--macm-surface-2); border-radius: 6px; }
.macm-archive-day { margin-bottom: 18px; }
.macm-archive-day-head { font-size: 13px; padding: 8px 12px; background: var(--macm-surface-2); border: 1px solid var(--macm-border); border-radius: 6px; margin-bottom: 6px; position: sticky; top: 0; z-index: 1; }
.macm-archive-day-list { display: flex; flex-direction: column; gap: 6px; padding-left: 4px; }
.macm-archive-row { display: flex; gap: 12px; padding: 10px 12px; background: var(--macm-surface); border: 1px solid var(--macm-border); border-radius: var(--macm-radius); }

/* ============================================================
   Kebab (three-dot) menu — used to consolidate row actions
   ============================================================ */
.macm-kebab-wrap { position: relative; display: inline-block; }
.macm-kebab-btn {
    background: transparent;
    border: 1px solid var(--macm-border);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    color: var(--macm-muted);
    line-height: 1;
    padding: 0;
    font-family: inherit;
}
.macm-kebab-btn:hover { background: var(--macm-surface-2); color: var(--macm-text); }
.macm-kebab-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
    min-width: 170px;
    padding: 4px;
    z-index: 50;
    display: none;
}
.macm-kebab-wrap.open .macm-kebab-menu { display: block; }
.macm-kebab-menu button,
.macm-kebab-menu a {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--macm-text);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.macm-kebab-menu button:hover,
.macm-kebab-menu a:hover { background: var(--macm-surface-2); }
.macm-kebab-menu .macm-kebab-divider {
    border-top: 1px solid var(--macm-border);
    margin: 4px 0;
}
.macm-kebab-menu button.danger { color: #dc2626; }
.macm-kebab-menu button.danger:hover { background: #fef2f2; }
@media (max-width: 480px) {
    .macm-kebab-menu { right: auto; left: 0; }
}
.macm-archive-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--macm-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.macm-archive-body { flex: 1; min-width: 0; }
.macm-archive-top { font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.macm-archive-action { background: var(--macm-surface-2); color: var(--macm-muted); font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.macm-archive-module { color: var(--macm-faint); font-size: 12px; }
.macm-archive-desc { font-size: 13px; color: var(--macm-text); margin-top: 4px; }
.macm-archive-time { font-size: 11px; color: var(--macm-faint); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ============================================================
   Invoice form — line items + sequential mark-paid
   ============================================================ */
.macm-inv-section {
    background: var(--macm-surface);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    padding: 16px;
    margin-bottom: 12px;
}
.macm-inv-section .macm-section-title { margin-top: 0; border-bottom: 0; padding-bottom: 0; }
.macm-inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.macm-inv-grid .macm-field-full { grid-column: 1 / -1; }

.macm-inv-line {
    display: grid;
    grid-template-columns: 1fr 80px 100px 90px 36px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--macm-surface-2);
}
.macm-inv-line:last-child { border-bottom: 0; }
.macm-inv-line input {
    padding: 9px 10px;
    border: 1px solid var(--macm-border);
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    background: var(--macm-surface);
    -webkit-appearance: none;
    appearance: none;
}
.macm-inv-line-total {
    font-weight: 600;
    text-align: right;
    color: var(--macm-text);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
}
.macm-inv-line-del {
    background: transparent;
    border: 1px solid var(--macm-border);
    border-radius: 6px;
    color: var(--macm-faint);
    width: 36px; height: 36px;
    cursor: pointer; font-size: 14px;
    transition: all 0.15s;
}
.macm-inv-line-del:hover {
    border-color: var(--macm-border-strong);
    color: var(--macm-text);
    background: var(--macm-surface-2);
}

#macm-inv-totals {
    background: var(--macm-surface-2);
    padding: 14px 16px;
    border-radius: var(--macm-radius);
}
.macm-inv-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
    color: var(--macm-muted);
}
.macm-inv-totals-row span:last-child { font-weight: 600; color: var(--macm-text); font-variant-numeric: tabular-nums; }
.macm-inv-totals-grand {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--macm-border-strong);
    font-size: 17px;
}
.macm-inv-totals-grand span { font-weight: 700; color: var(--macm-text); }
.macm-inv-totals-grand span:last-child { color: var(--macm-primary); }

.macm-inv-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    flex-wrap: wrap;
}
.macm-inv-actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

.macm-inv-post-actions {
    background: var(--macm-primary-soft);
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    padding: 16px;
    margin-top: 14px;
}
.macm-inv-post-success {
    font-size: 15px;
    font-weight: 600;
    color: var(--macm-primary-on-soft);
    margin-bottom: 12px;
}
.macm-inv-post-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.macm-radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.macm-radio {
    flex: 1;
    min-width: 110px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--macm-border);
    border-radius: var(--macm-radius);
    cursor: pointer;
    font-size: 13px;
    background: var(--macm-surface);
    transition: all 0.15s;
}
.macm-radio:has(input:checked) {
    border-color: var(--macm-primary);
    background: var(--macm-primary-soft);
    color: var(--macm-primary-on-soft);
    font-weight: 600;
}
.macm-radio input { margin: 0; }

/* ============================================================
   Mobile (hamburger + responsive)
   ============================================================ */
.macm-mobile-toggle {
    display: none;
    position: sticky; top: 0;
    z-index: 90;
    width: 100%;
    align-items: center; gap: 10px;
    padding: 12px 16px;
    background: var(--macm-surface);
    color: var(--macm-text);
    border: 0;
    border-bottom: 1px solid var(--macm-border);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    font-family: inherit;
}
.macm-hamburger-icon {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: var(--macm-surface-2);
    border-radius: 6px;
    flex-shrink: 0;
}
.macm-mobile-title { flex: 1; }
.macm-sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.macm-sidebar-backdrop.open { display: block; opacity: 1; }

@media (max-width: 1100px) {
    .macm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
    .macm-app {
        flex-direction: column;
        margin: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        min-height: 100vh;
        /* Clear the theme's sticky mobile header so the dashboard isn't covered.
           OceanWP's mobile header is typically ~60-70px; this is a safe default. */
        padding-top: 70px;
    }
    .macm-mobile-toggle {
        display: flex;
        /* Push the hamburger bar below the theme header too */
        top: 70px;
    }
    .macm-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 280px; max-width: 85vw;
        height: 100vh;
        padding: 18px 14px;
        z-index: 99980; /* below theme header (usually 99999) so close button still works */
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
        border-right: 1px solid var(--macm-border);
    }
    .macm-sidebar.open { transform: translateX(0); }
    .macm-nav { gap: 2px; flex: 1; }
    .macm-main { padding: 16px; width: 100%; }
    .macm-topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .macm-topbar h1 { font-size: 20px; }
    .macm-topbar-right { width: 100%; flex-wrap: wrap; }
    .macm-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .macm-stat { padding: 12px; }
    .macm-stat-num { font-size: 20px; }
    .macm-stat-icon { width: 36px; height: 36px; font-size: 16px; }
    .macm-card { padding: 14px; border-radius: var(--macm-radius); }
    .macm-card-head { flex-wrap: wrap; gap: 8px; }
    .macm-card-head h3 { font-size: 15px; }
    .macm-form-grid, .macm-form-grid-2 { grid-template-columns: 1fr; }
    .macm-table { font-size: 12px; min-width: 480px; }
    .macm-table th, .macm-table td { padding: 8px 10px; }
    .macm-archive-filters { width: 100%; }
    .macm-archive-filters select { flex: 1; min-width: 0; }
    .macm-modal-card { padding: 20px 16px; margin: 10px; max-height: 90vh; }
    .macm-modal-large { max-width: 100%; }
    .macm-auth-card { padding: 28px 22px; }
    .macm-record { flex-direction: column; align-items: flex-start; gap: 8px; }
    .macm-record-actions { flex-direction: row; width: 100%; flex-wrap: wrap; align-items: center; }
    .macm-lesson-current { padding: 14px 16px; }
    .macm-lesson-title, .macm-lesson-current .title { font-size: 18px; }
    .macm-live-bar { flex-wrap: wrap; }

    .macm-inv-grid { grid-template-columns: 1fr; }
    .macm-inv-line {
        grid-template-columns: 1fr 36px;
        grid-template-areas:
            "desc del"
            "qty rate"
            "total total";
        gap: 6px;
        padding: 10px;
        background: var(--macm-surface-2);
        border: 1px solid var(--macm-border);
        border-radius: var(--macm-radius);
        margin-bottom: 8px;
    }
    .macm-inv-line .macm-inv-line-desc  { grid-area: desc; }
    .macm-inv-line .macm-inv-line-del   { grid-area: del; }
    .macm-inv-line .macm-inv-line-qty   { grid-area: qty; }
    .macm-inv-line .macm-inv-line-rate  { grid-area: rate; }
    .macm-inv-line .macm-inv-line-total {
        grid-area: total;
        text-align: right;
        font-size: 15px;
        background: var(--macm-surface);
        padding: 6px 10px;
        border-radius: 4px;
        border: 1px solid var(--macm-border);
    }
    .macm-inv-actions {
        position: sticky;
        bottom: -16px;
        background: var(--macm-surface);
        margin: 0 -16px -16px;
        padding: 12px 16px;
        border-top: 1px solid var(--macm-border);
        z-index: 10;
        box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05);
    }
    .macm-inv-actions-right { flex: 1; justify-content: flex-end; }
}
@media (max-width: 480px) {
    .macm-stats { grid-template-columns: 1fr; }
    .macm-mobile-toggle { padding: 10px 14px; font-size: 14px; }
    .macm-main { padding: 12px; }
    .macm-topbar h1 { font-size: 18px; }
    .macm-card { padding: 12px; }
    .macm-act-item { padding: 8px; gap: 8px; }
    .macm-act-avatar { width: 32px; height: 32px; font-size: 13px; }
    .macm-cert-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .macm-cert-meta { width: 100%; justify-content: space-between; }
    .macm-archive-row { flex-direction: column; gap: 6px; }
    .macm-archive-avatar { width: 28px; height: 28px; font-size: 12px; }
}
