/* ==========================================================================
   MARTIALTEK UI 2 - action-first shell, theme tokens, modals, components.
   Loaded AFTER dma.css. Every color comes from the school's theme
   (dma_tbl_whitelabel via site.master), so DMA Dark, Clean White and every
   preset work without touching this file.
   ========================================================================== */

:root {
    --mt-accent: var(--theme-primary, #D21F35);
    --mt-good: var(--theme-success, #1C7A48);
    --mt-bad: var(--theme-danger, #D21F35);
    --mt-bg: var(--theme-bg-base, #F5F5F7);
    --mt-card: var(--theme-bg-card, #FFFFFF);
    --mt-input: var(--theme-input-bg, #FFFFFF);
    --mt-ink: var(--theme-text-main, #141418);
    --mt-muted: var(--theme-text-muted, #5E5F68);
    --mt-line: var(--theme-border, #E6E6EB);
    --mt-r: var(--theme-radius, 16px);
    --mt-soft: color-mix(in srgb, var(--mt-ink) 5%, var(--mt-card));
    --mt-soft2: color-mix(in srgb, var(--mt-ink) 9%, var(--mt-card));
    --mt-accent-soft: color-mix(in srgb, var(--mt-accent) 12%, var(--mt-card));
    --mt-good-soft: color-mix(in srgb, var(--mt-good) 14%, var(--mt-card));
    --mt-bad-soft: color-mix(in srgb, var(--mt-bad) 12%, var(--mt-card));
    --mt-warn: #B26B00;
    --mt-warn-soft: color-mix(in srgb, #F0A020 16%, var(--mt-card));
    --mt-info: #2456D6;
    --mt-info-soft: color-mix(in srgb, #2456D6 12%, var(--mt-card));
    --mt-shadow: 0 10px 30px rgba(0,0,0,0.07);
    --mt-shadow-lg: 0 30px 80px rgba(0,0,0,0.28);
    --mt-sidebar: 268px;
    --mt-font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mt-display: 'Bricolage Grotesque', 'Geist', -apple-system, sans-serif;
}
html.mt-dark { color-scheme: dark; --mt-shadow: 0 10px 30px rgba(0,0,0,0.35); --mt-warn: #F5B84A; --mt-info: #7AA2FF; }

body, html { font-family: var(--mt-font) !important; -webkit-font-smoothing: antialiased; }
body.mt-shell { margin: 0; background: var(--mt-bg) !important; color: var(--mt-ink); }

/* ---------- Shell ---------- */
.mt-app { display: flex; min-height: 100vh; }
.mt-side {
    position: fixed; inset: 0 auto 0 0; width: var(--mt-sidebar); z-index: 1040;
    background: var(--mt-card); border-right: 1px solid var(--mt-line);
    display: flex; flex-direction: column; padding: 18px 14px; box-sizing: border-box; overflow-y: auto;
}
.mt-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: var(--mt-ink) !important; text-decoration: none !important; }
.mt-brand-mark { width: 44px; height: 44px; border-radius: 13px; background: var(--mt-accent); color: #fff; display: grid; place-items: center; font-family: var(--mt-display); font-weight: 800; font-size: 22px; flex: none; overflow: hidden; }
.mt-brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.mt-brand-name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mt-brand-name b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-brand-name small { font-size: 12.5px; color: var(--mt-muted) !important; }

/* ---------- School brand at the top of the menu (staff + members) ----------
   The school's logo first, centered; the school's name under it; then a quiet
   "Powered by MartialTek". Same block on the staff and member sides. */
.mt-brandx { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin: 2px 0 14px; padding: 18px 12px 16px; border-radius: 18px; color: var(--mt-ink) !important; text-decoration: none !important; background: linear-gradient(180deg, var(--mt-soft) 0%, transparent 100%); flex: none; transition: background .2s ease; }
.mt-brandx::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 1px; background: var(--mt-line); }
.mt-brandx:hover { background: linear-gradient(180deg, var(--mt-accent-soft) 0%, transparent 100%); }
.mt-brandx-logo { display: flex; align-items: center; justify-content: center; max-width: 100%; }
.mt-brandx-logo img { display: block; max-width: 196px; max-height: 84px; width: auto; height: auto; object-fit: contain; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.14); transition: transform .2s ease; }
.mt-brandx:hover .mt-brandx-logo img { transform: translateY(-1px) scale(1.02); }
.mt-brandx-logo.is-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--mt-accent); color: #fff; font: 800 30px var(--mt-display); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.mt-brandx-name { font: 800 17px/1.2 var(--mt-display); letter-spacing: -.01em; color: var(--mt-ink); max-width: 100%; overflow-wrap: anywhere; }
.mt-brandx-by { margin-top: -4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mt-muted); }
.mt-brandx-by b { font-weight: 800; color: var(--mt-ink); opacity: .75; }
.mt-nav-h { padding: 16px 12px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: var(--mt-muted); text-transform: uppercase; }
.mt-nav a {
    display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 12px;
    font-size: 14.5px; font-weight: 600; color: var(--mt-ink) !important; text-decoration: none !important; opacity: 1 !important;
}
.mt-nav a .fa { width: 20px; text-align: center; font-size: 16px; color: var(--mt-muted); }
.mt-nav a:hover { background: var(--mt-soft); }
.mt-nav a.on { background: var(--mt-accent-soft); color: var(--mt-accent) !important; }
.mt-nav a.on .fa { color: var(--mt-accent); }
.mt-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; box-sizing: border-box; border-radius: 11px; background: var(--mt-accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.mt-count.soft { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mt-side-foot { margin-top: auto; padding-top: 12px; }
.mt-me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--mt-line); margin-top: 8px; }
.mt-me-av { width: 38px; height: 38px; border-radius: 19px; background: var(--mt-ink); color: var(--mt-card); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.mt-me-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mt-me-txt b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-me-txt small { font-size: 12.5px; color: var(--mt-muted) !important; }
.mt-me a, .mt-me .mt-iconbtn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--mt-muted) !important; }
.mt-me a:hover { background: var(--mt-soft); }

.mt-body { flex: 1; min-width: 0; margin-left: var(--mt-sidebar); display: flex; flex-direction: column; }
.mt-top { position: sticky; top: 0; z-index: 1030; padding: 16px 36px 12px; background: color-mix(in srgb, var(--mt-bg) 86%, transparent); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px); display: flex; gap: 12px; align-items: center; }
.mt-burger { display: none; width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--mt-line); background: var(--mt-card); color: var(--mt-ink); font-size: 18px; }
.mt-content { padding: 8px 36px 64px; box-sizing: border-box; width: 100%; max-width: var(--mt-maxw, 2200px); }
.mt-content .apple-main-container { max-width: 100% !important; margin: 8px 0 40px !important; }
.mt-scrim { display: none; }

@media (max-width: 991px) {
    .mt-side { transform: translateX(-104%); transition: transform .25s ease; box-shadow: var(--mt-shadow-lg); }
    body.mt-nav-open .mt-side { transform: none; }
    body.mt-nav-open .mt-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
    .mt-body { margin-left: 0; }
    .mt-burger { display: grid; place-items: center; flex: none; }
    .mt-top { padding: 12px 16px; }
    .mt-content { padding: 4px 16px 48px; }
}

/* ---------- The "I want to…" bar ---------- */
.mt-ask { position: relative; flex: 1; min-width: 0; }
.mt-ask-box { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: var(--mt-card); border: 2px solid var(--mt-line); border-radius: 18px; box-shadow: var(--mt-shadow); box-sizing: border-box; transition: border-color .15s; }
.mt-ask.open .mt-ask-box { border-color: var(--mt-accent); }
.mt-ask-box .fa-search { color: var(--mt-muted); font-size: 18px; }
.mt-ask-box input.mt-ask-in {
    flex: 1; min-width: 0; height: 100% !important; border: 0 !important; background: transparent !important; box-shadow: none !important;
    padding: 0 !important; font-family: var(--mt-font); font-size: 16.5px !important; color: var(--mt-ink) !important; outline: none !important;
}
.mt-ask-box input.mt-ask-in::placeholder { color: var(--mt-muted) !important; opacity: .85 !important; }
.mt-kbd { font-size: 12px; font-weight: 600; color: var(--mt-muted); border: 1px solid var(--mt-line); border-radius: 8px; padding: 3px 8px; white-space: nowrap; }
.mt-ask-pop {
    display: none; position: absolute; left: 0; right: 0; top: 64px; z-index: 1060; background: var(--mt-card); border: 1px solid var(--mt-line);
    border-radius: 20px; box-shadow: var(--mt-shadow-lg); padding: 8px; max-height: min(70vh, 640px); overflow-y: auto;
}
.mt-ask.open .mt-ask-pop { display: block; }
.mt-ask-h { padding: 10px 12px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; color: var(--mt-muted); text-transform: uppercase; }
.mt-ask-item { display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 8px 12px; border-radius: 13px; color: var(--mt-ink) !important; text-decoration: none !important; cursor: pointer; opacity: 1 !important; }
.mt-ask-item.sel, .mt-ask-item:hover { background: var(--mt-soft); }
.mt-ask-ic { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--mt-soft2); color: var(--mt-ink); display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.mt-ask-item.sel .mt-ask-ic { background: var(--mt-accent); color: #fff; }
.mt-ask-ic.person { background: var(--mt-ink); color: var(--mt-card); font-size: 12.5px; }
.mt-ask-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mt-ask-t b { font-size: 15.5px; font-weight: 600; }
.mt-ask-t b mark { background: none; color: var(--mt-accent); padding: 0; }
.mt-ask-t small { font-size: 13px; color: var(--mt-muted) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-ask-where { font-size: 12px; font-weight: 600; color: var(--mt-muted); white-space: nowrap; }
.mt-ask-empty { padding: 18px 14px; color: var(--mt-muted); font-size: 15px; }
.mt-ask-foot { display: flex; gap: 14px; padding: 10px 12px 4px; border-top: 1px solid var(--mt-line); margin-top: 6px; font-size: 12px; color: var(--mt-muted); flex-wrap: wrap; }

/* ---------- Page building blocks (new pages) ---------- */
.mt-page { display: flex; flex-direction: column; gap: 26px; }
.mt-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.mt-h1 { margin: 0 !important; font-family: var(--mt-display) !important; font-weight: 800 !important; font-size: clamp(30px, 3.4vw, 42px) !important; letter-spacing: -0.02em; line-height: 1.08 !important; color: var(--theme-text-headers, var(--mt-ink)) !important; }
.mt-sub { margin: 6px 0 0 !important; font-size: 16.5px !important; color: var(--mt-muted) !important; }
.mt-h2 { margin: 0 !important; font-size: 19px !important; font-weight: 700 !important; color: var(--mt-ink) !important; }
.mt-cap { margin: 0 !important; font-size: 12px !important; font-weight: 700 !important; letter-spacing: .07em; text-transform: uppercase; color: var(--mt-muted) !important; }
.mt-card { background: var(--mt-card); border: 1px solid var(--mt-line); border-radius: calc(var(--mt-r) + 6px); padding: 22px; box-shadow: none; }
.mt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 14px; }
.mt-grid.sm { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.mt-grid.lg { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.mt-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.mt-split { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.mt-split > .mt-main-col { flex: 999 1 520px; min-width: 0; }
.mt-split > .mt-aside-col { flex: 1 1 320px; min-width: 0; }

.mt-door { display: flex; flex-direction: column; gap: 14px; min-height: 140px; padding: 20px; background: var(--mt-card); border: 1px solid var(--mt-line); border-radius: calc(var(--mt-r) + 6px); color: var(--mt-ink) !important; text-decoration: none !important; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; opacity: 1 !important; font: inherit; }
.mt-door:hover { border-color: color-mix(in srgb, var(--mt-ink) 22%, var(--mt-card)); box-shadow: var(--mt-shadow); transform: translateY(-2px); }
.mt-door.on { border: 2px solid var(--mt-accent); }
.mt-door b { font-size: 18px; font-weight: 700; display: block; }
.mt-door small { font-size: 14px; color: var(--mt-muted) !important; display: block; margin-top: 3px; line-height: 1.4; }
.mt-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 19px; flex: none; background: var(--mt-soft2); color: var(--mt-ink); }
.mt-ic.red { background: var(--mt-accent-soft); color: var(--mt-accent); }
.mt-ic.green { background: var(--mt-good-soft); color: var(--mt-good); }
.mt-ic.blue { background: var(--mt-info-soft); color: var(--mt-info); }
.mt-ic.amber { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mt-ic.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }

.mt-list { background: var(--mt-card); border: 1px solid var(--mt-line); border-radius: calc(var(--mt-r) + 6px); overflow: hidden; }
.mt-li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--mt-line); flex-wrap: wrap; }
.mt-li:first-child { border-top: 0; }
.mt-li-main { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mt-li-main b { font-size: 15.5px; font-weight: 700; }
.mt-li-main small { font-size: 13.5px; color: var(--mt-muted) !important; }
.mt-av { width: 42px; height: 42px; border-radius: 21px; background: var(--mt-soft2); display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; color: var(--mt-ink); overflow: hidden; }
.mt-av img { width: 100%; height: 100%; object-fit: cover; }

.mt-tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; font-weight: 700; background: var(--mt-soft2); color: var(--mt-ink); white-space: nowrap; }
.mt-tag.good { background: var(--mt-good-soft); color: var(--mt-good); }
.mt-tag.bad { background: var(--mt-bad-soft); color: var(--mt-bad); }
.mt-tag.warn { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mt-tag.info { background: var(--mt-info-soft); color: var(--mt-info); }

.mt-chip { height: 40px; padding: 0 15px; border-radius: 20px; border: 1.5px solid var(--mt-line); background: var(--mt-card); color: var(--mt-ink); font: 600 14px var(--mt-font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none !important; }
.mt-chip:hover { background: var(--mt-soft); }
.mt-chip.on { background: var(--mt-ink); border-color: var(--mt-ink); color: var(--mt-card) !important; }
.mt-chip .n { opacity: .7; font-weight: 500; }

.mt-btn { height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--mt-line); background: var(--mt-card); color: var(--mt-ink) !important; font: 700 15px var(--mt-font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none !important; white-space: nowrap; opacity: 1 !important; }
.mt-btn:hover { background: var(--mt-soft); }
.mt-btn.go { background: var(--mt-accent); border-color: var(--mt-accent); color: #fff !important; }
.mt-btn.go:hover { filter: brightness(1.06); background: var(--mt-accent); }
.mt-btn.dark { background: var(--mt-ink); border-color: var(--mt-ink); color: var(--mt-card) !important; }
.mt-btn.ghost { border-color: transparent; background: transparent; }
.mt-btn.danger { background: var(--mt-bad-soft); border-color: transparent; color: var(--mt-bad) !important; }
.mt-btn.sm { height: 38px; padding: 0 13px; border-radius: 11px; font-size: 14px; }
.mt-btn.lg { height: 56px; padding: 0 26px; border-radius: 16px; font-size: 17px; font-weight: 800; }
.mt-btn[disabled] { opacity: .45 !important; cursor: not-allowed; }

.mt-stat { display: flex; flex-direction: column; gap: 2px; }
.mt-stat span { font-size: 13.5px; color: var(--mt-muted); font-weight: 600; }
.mt-stat b { font-family: var(--mt-display); font-size: 32px; font-weight: 800; line-height: 1.1; }

.mt-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-step { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 6px; border-radius: 20px; background: var(--mt-soft); color: var(--mt-muted); font-weight: 700; font-size: 14.5px; }
.mt-step i { width: 28px; height: 28px; border-radius: 14px; background: var(--mt-card); display: grid; place-items: center; font-style: normal; font-size: 13px; }
.mt-step.on { background: var(--mt-accent-soft); color: var(--mt-accent); }
.mt-step.on i { background: var(--mt-accent); color: #fff; }
.mt-step.done i { background: var(--mt-good); color: #fff; }

.mt-menu { position: relative; display: inline-block; }
.mt-menu > summary { list-style: none; cursor: pointer; }
.mt-menu > summary::-webkit-details-marker { display: none; }
.mt-menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1050; min-width: 230px; background: var(--mt-card); border: 1px solid var(--mt-line); border-radius: 16px; box-shadow: var(--mt-shadow-lg); padding: 6px; display: flex; flex-direction: column; }
.mt-menu-pop a, .mt-menu-pop button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: none; font: 600 14px var(--mt-font); color: var(--mt-ink) !important; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.mt-menu-pop a:hover, .mt-menu-pop button:hover { background: var(--mt-soft); }
.mt-menu-pop .danger { color: var(--mt-bad) !important; }
/* mt-ui.js adds these when a menu would fall off the page: "up" opens it
   above its button, "left" lines it up with the button's left edge. */
.mt-menu-pop.up { top: auto; bottom: calc(100% + 6px); }
.mt-menu-pop.left { right: auto; left: 0; }
/* While any menu is open the floating chat bubble steps aside. */
body.mt-menu-open #scwBubble, body.mt-menu-open #mcwBubble { visibility: hidden !important; }

.mt-where { background: var(--mt-card); border: 1px dashed var(--mt-line); border-radius: 18px; padding: 16px 20px; }
.mt-where summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.mt-where summary em { font-style: normal; color: var(--mt-accent); }
.mt-where-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 6px 24px; margin-top: 12px; font-size: 13.5px; color: var(--mt-muted); line-height: 1.5; }
.mt-where-grid b { color: var(--mt-ink); }

/* ---------- Gentle refresh of every legacy page ---------- */
.mt-shell label { text-transform: none !important; letter-spacing: 0 !important; font-size: 13.5px !important; font-weight: 600 !important; }
.mt-shell .apple-card, .mt-shell .pay-card { border-radius: calc(var(--mt-r) + 6px) !important; box-shadow: none !important; padding: 24px !important; }
.mt-shell .apple-card-title { font-size: 19px !important; font-weight: 700 !important; }
.mt-shell .header-title { font-family: var(--mt-display); }
.mt-shell .form-control, .mt-shell select, .mt-shell input[type="text"], .mt-shell input[type="number"], .mt-shell input[type="date"], .mt-shell input[type="email"], .mt-shell input[type="password"], .mt-shell textarea { border-radius: 12px !important; height: 46px !important; font-size: 15px !important; }
.mt-shell textarea, .mt-shell textarea.form-control { height: auto !important; }
.mt-shell .form-control:focus { border-color: var(--mt-accent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--mt-accent) 18%, transparent) !important; }
.mt-shell .btn { border-radius: 12px !important; font-family: var(--mt-font) !important; }
.mt-shell .btn-primary { background: var(--mt-accent) !important; box-shadow: none !important; }
.mt-shell .label, .mt-shell .badge, .mt-shell .badge-pill { text-transform: none !important; letter-spacing: 0 !important; font-size: 12px !important; border-radius: 8px !important; }
.mt-shell .apple-table th { text-transform: none !important; font-size: 12.5px !important; letter-spacing: 0 !important; font-weight: 700 !important; }
.mt-shell .bento-card { border-radius: calc(var(--mt-r) + 4px) !important; box-shadow: none !important; }
.mt-shell .nav-wrapper { display: none !important; }

/* ---------- Bootstrap modals, made gorgeous ---------- */
.modal-backdrop.in { opacity: .45 !important; }
.modal-backdrop { background: #0B0B0F !important; }
.modal.fade .modal-dialog { transform: translateY(18px) scale(.98); transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s; }
.modal.in .modal-dialog { transform: none; }
.modal-dialog { margin-top: 6vh !important; }
.modal-content { border-radius: 26px !important; border: 1px solid var(--mt-line) !important; box-shadow: var(--mt-shadow-lg) !important; padding: 26px !important; background: var(--mt-card) !important; }
.modal-header { padding: 0 0 16px !important; margin: 0 0 18px !important; }
.modal-title { font-family: var(--mt-display) !important; font-size: 23px !important; font-weight: 800 !important; }
.modal-header .close { width: 38px; height: 38px; border-radius: 19px; background: var(--mt-soft) !important; opacity: 1 !important; color: var(--mt-ink) !important; text-shadow: none !important; font-size: 22px; line-height: 1; }
.modal-footer { padding: 18px 0 0 !important; margin-top: 18px !important; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- MT dialogs (replace alert / confirm / prompt) ---------- */
.mtd-scrim { position: fixed; inset: 0; z-index: 20000; background: rgba(11,11,15,.48); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .18s; }
.mtd-scrim.in { opacity: 1; }
.mtd { width: min(460px, 100%); background: var(--mt-card); color: var(--mt-ink); border: 1px solid var(--mt-line); border-radius: 26px; box-shadow: var(--mt-shadow-lg); padding: 26px; box-sizing: border-box; transform: translateY(14px) scale(.98); transition: transform .22s cubic-bezier(.2,.8,.2,1); font-family: var(--mt-font); }
.mtd-scrim.in .mtd { transform: none; }
.mtd-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; background: var(--mt-info-soft); color: var(--mt-info); }
.mtd-ic.ok { background: var(--mt-good-soft); color: var(--mt-good); }
.mtd-ic.bad { background: var(--mt-bad-soft); color: var(--mt-bad); }
.mtd-ic.warn { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mtd h3 { margin: 0 0 8px !important; font-family: var(--mt-display) !important; font-size: 22px !important; font-weight: 800 !important; line-height: 1.2 !important; color: var(--mt-ink) !important; }
.mtd p { margin: 0 !important; font-size: 15.5px !important; line-height: 1.55 !important; color: color-mix(in srgb, var(--mt-ink) 80%, var(--mt-card)) !important; white-space: pre-line; word-break: break-word; }
.mtd input.mtd-in { margin-top: 14px; width: 100% !important; height: 50px !important; border-radius: 14px !important; border: 1.5px solid var(--mt-line) !important; background: var(--mt-input) !important; padding: 0 14px !important; font: 16px var(--mt-font) !important; color: var(--mt-ink) !important; box-sizing: border-box; }
.mtd-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.mtd-btns .mt-btn { min-width: 110px; }

.mt-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 20001; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.mt-toast { display: flex; gap: 12px; align-items: flex-start; background: var(--mt-ink); color: var(--mt-card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--mt-shadow-lg); font: 600 14.5px/1.45 var(--mt-font); transform: translateY(12px); opacity: 0; transition: all .22s; }
.mt-toast.in { transform: none; opacity: 1; }
.mt-toast .fa { margin-top: 3px; }

.mt-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt-shell a:focus-visible, .mt-shell button:focus-visible, .mt-shell input:focus-visible, .mt-shell summary:focus-visible, .mt-shell select:focus-visible { outline: 3px solid var(--mt-info); outline-offset: 2px; }

/* ==========================================================================
   POLISH v3 - one gutter, one rhythm, balanced grids, buttons that fit.
   Loaded last on purpose: these rules win over the older ones above.
   ========================================================================== */
/* The page uses the whole window. --mt-maxw only stops text lines getting
   too long on very wide monitors; below that the page fills what it has. */
:root { --mt-gutter: 40px; --mt-maxw: 2200px; --mt-gap: 16px; --mt-rhythm: 28px; }

/* ---- Shell ---- */
/* Paint the sidebar column on the page itself, so the menu is a full-height
   panel even in long page screenshots. */
@media (min-width: 992px) {
    .mt-app { background: linear-gradient(to right, var(--mt-card) 0, var(--mt-card) calc(var(--mt-sidebar) - 1px), var(--mt-line) calc(var(--mt-sidebar) - 1px), var(--mt-line) var(--mt-sidebar), transparent var(--mt-sidebar)); }
}
.mt-side { padding: 22px 16px 16px; }
.mt-brand { padding: 2px 12px 22px; gap: 12px; }
.mt-brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.mt-nav-h { padding: 18px 12px 6px; font-size: 11px; letter-spacing: .09em; }
.mt-nav { display: flex; flex-direction: column; gap: 2px; }
.mt-nav a { height: 40px; padding: 0 12px; gap: 12px; font-size: 14.5px; border-radius: 10px; }
.mt-nav a .fa { width: 18px; font-size: 15px; flex: none; }
.mt-nav a .mt-ext { margin-left: auto; width: auto; font-size: 11px; opacity: .55; }
.mt-side-foot { padding-top: 16px; border-top: 0; }
.mt-me { padding: 14px 12px 2px; margin-top: 10px; }
.mt-count { min-width: 20px; height: 20px; font-size: 11.5px; border-radius: 10px; padding: 0 6px; }

/* One gutter for the bar and the page, and the same left/right edges. */
.mt-top { padding: 20px var(--mt-gutter) 14px; }
.mt-top > .mt-ask { max-width: calc(var(--mt-maxw) - (2 * var(--mt-gutter))); }
.mt-ask-box { height: 52px; border-width: 1.5px; border-radius: 16px; }
.mt-content.apple-main-container, main.mt-content {
    max-width: var(--mt-maxw) !important; width: 100% !important; margin: 0 !important;
    padding: 18px var(--mt-gutter) 72px !important; box-sizing: border-box !important;
}
@media (max-width: 991px) {
    :root { --mt-gutter: 16px; }
    .mt-top { padding: 12px var(--mt-gutter); }
    .mt-content.apple-main-container, main.mt-content { padding: 8px var(--mt-gutter) 56px !important; }
}

/* ---- Page rhythm ---- */
.mt-page { gap: var(--mt-rhythm); }
.mt-head { align-items: center; gap: 20px; min-height: 56px; }
.mt-head > div:first-child { flex: 1 1 360px; min-width: 0; }
.mt-head > :not(:first-child) { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-h1 { font-size: clamp(30px, 3vw, 40px) !important; line-height: 1.1 !important; }
.mt-sub { margin-top: 8px !important; font-size: 16px !important; line-height: 1.45 !important; }
.mt-h2 { font-size: 19px !important; line-height: 1.3 !important; }
.mt-card { padding: 24px; border-radius: 20px; }
.mt-grid { gap: var(--mt-gap); }
.mt-split { gap: var(--mt-gap); }

/* ---- Buttons: one size scale, text always centred and contained ---- */
.mt-btn {
    height: 44px; padding: 0 18px; border-radius: 12px; gap: 8px;
    font: 650 14.5px/1 var(--mt-font); letter-spacing: 0;
    box-sizing: border-box; vertical-align: middle; flex: none; max-width: 100%;
}
.mt-btn > .fa { font-size: 14px; width: auto; line-height: 1; }
.mt-btn.sm { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; }
.mt-btn.sm > .fa { font-size: 13px; }
.mt-btn.lg { height: 52px; padding: 0 24px; border-radius: 14px; font-size: 16px; }
.mt-head .mt-btn, .mt-head summary.mt-btn { height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14.5px; }
.mt-head .mt-btn.ghost { padding: 0 12px; }
/* Bootstrap buttons get the same centring */
.mt-shell .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2; }
.mt-shell .btn-block { display: flex; width: 100%; }
/* Buttons inside old-style tables used to be forced to inline-block */
.apple-table td a.mt-btn, .apple-table td button.mt-btn { display: inline-flex !important; margin: 0 !important; }
.apple-table td a.mt-btn i.fa { width: auto !important; height: auto !important; background: none !important; border: 0 !important; font-size: 13px !important; }

/* ---- Chips ---- */
.mt-chip { height: 38px; padding: 0 16px; border-radius: 19px; border-width: 1px; font: 600 14px/1 var(--mt-font); gap: 7px; box-sizing: border-box; }
.mt-chip > .fa { font-size: 13px; }
.mt-chip input[type="checkbox"] { margin: 0 !important; position: static !important; flex: none; width: 16px !important; height: 16px !important; }

/* ---- Doors: grids that always come out even ---- */
.mt-door { min-height: 136px; padding: 22px; gap: 16px; border-radius: 20px; box-sizing: border-box; }
.mt-door.on { border: 1px solid var(--mt-accent); box-shadow: inset 0 0 0 1px var(--mt-accent); }
.mt-door b { font-size: 17px; line-height: 1.3; }
.mt-door small { font-size: 14px; line-height: 1.45; margin-top: 4px; }
.mt-door .mt-ic { width: 44px; height: 44px; border-radius: 13px; font-size: 18px; }
.mt-grid:has(> .mt-door:nth-child(2):last-child)  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mt-grid:has(> .mt-door:nth-child(3):last-child),
.mt-grid:has(> .mt-door:nth-child(6):last-child),
.mt-grid:has(> .mt-door:nth-child(9):last-child)  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt-grid:has(> .mt-door:nth-child(4):last-child),
.mt-grid:has(> .mt-door:nth-child(8):last-child)  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt-grid:has(> .mt-door:nth-child(5):last-child)  { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1280px) {
    .mt-grid:has(> .mt-door:nth-child(5):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .mt-grid:has(> .mt-door:nth-child(4):last-child),
    .mt-grid:has(> .mt-door:nth-child(8):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .mt-grid:has(> .mt-door) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .mt-grid:has(> .mt-door:nth-child(3):last-child) { grid-template-columns: 1fr !important; }
    .mt-door { min-height: 0; }
}
@media (max-width: 480px) { .mt-grid:has(> .mt-door) { grid-template-columns: 1fr !important; } }
/* Big screens: more doors per row instead of wider doors. */
@media (min-width: 1800px) {
    .mt-grid:has(> .mt-door:nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---- Numbers ---- */
.mt-stat { gap: 4px; }
.mt-stat > span { font-size: 13.5px; font-weight: 600; color: var(--mt-muted); }
.mt-stat b { font-size: 30px; line-height: 1.1; }
.mt-stat b span, .mt-stat b * { font: inherit !important; color: inherit !important; letter-spacing: inherit !important; }

/* ---- Lists ---- */
.mt-li { padding: 16px 20px; gap: 14px; }
.mt-wait .mt-li > .mt-btn.sm { min-width: 112px; }

/* ---- Forms: small things that looked broken ---- */
.mt-shell select.mt-mini-select { height: 34px !important; font-size: 13.5px !important; padding: 0 30px 0 12px !important; border-radius: 10px !important; min-width: 138px; width: auto !important; }
.pin-feedback:empty { display: none !important; }
.input-group:has(.pin-feedback:empty) > .form-control { border-radius: 12px !important; }

/* ---- Tags and small badges line up with text ---- */
.mt-tag { height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12px; line-height: 1; }
label.mt-chip, .mt-shell label.mt-chip { display: inline-flex !important; align-items: center; margin: 0 !important; font-size: 14px !important; }
.mt-shell label > input[type="checkbox"], .mt-shell label > input[type="radio"] { vertical-align: middle; margin-top: -2px; }

/* Home "Your programs": pick a column count that leaves no lonely tile */
@media (min-width: 1200px) {
    .mt-progs:has(> .tile-wrapper:nth-child(3):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(6):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(9):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .mt-progs:has(> .tile-wrapper:nth-child(4):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(7):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(8):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(11):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(12):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .mt-progs:has(> .tile-wrapper:nth-child(5):last-child),
    .mt-progs:has(> .tile-wrapper:nth-child(10):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
}

/* Modal headers: title on the left, the X on the right - always, whatever
   order the page wrote them in. Any line under the title wraps below. */
.modal-header > .modal-title, .modal-header > h4, .modal-header > h3 { order: 1; flex: 1 1 auto; min-width: 0; text-align: left; }
.modal-header > .close { order: 2; margin: 0 0 0 auto !important; flex: none; float: none !important; }
.modal-header > :not(.close):not(.modal-title):not(h4):not(h3) { order: 3; flex-basis: 100%; }

/* Toasts sit above the chat bubble instead of under it, and never block a
   click on whatever is underneath them (they are only messages). */
.mt-toasts { bottom: 96px; pointer-events: none; }

/* ---------- Colored tiles that work in light AND dark color schemes ----------
   The old tile colors (dma.css card-blue etc.) were fixed pale backgrounds, so
   in a dark scheme the white text on them disappeared (program names on Home).
   Now each tile is a light tint of its color mixed into the scheme's own card
   color, and the text uses the scheme's own text color - readable in both. */
.mt-shell .bento-card.card-blue { background-color: color-mix(in srgb, #3b82f6 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #3b82f6 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-green { background-color: color-mix(in srgb, #22c55e 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #22c55e 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-purple { background-color: color-mix(in srgb, #a855f7 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #a855f7 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-orange { background-color: color-mix(in srgb, #f59e0b 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #f59e0b 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-pink { background-color: color-mix(in srgb, #ec4899 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #ec4899 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-teal { background-color: color-mix(in srgb, #14b8a6 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #14b8a6 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-indigo { background-color: color-mix(in srgb, #6366f1 13%, var(--mt-card)) !important; border-color: color-mix(in srgb, #6366f1 32%, var(--mt-line)) !important; }
.mt-shell .bento-card.card-blue h3, .mt-shell .bento-card.card-blue p, .mt-shell .bento-card.card-blue span, .mt-shell .bento-card.card-blue b, .mt-shell .bento-card.card-green h3, .mt-shell .bento-card.card-green p, .mt-shell .bento-card.card-green span, .mt-shell .bento-card.card-green b, .mt-shell .bento-card.card-purple h3, .mt-shell .bento-card.card-purple p, .mt-shell .bento-card.card-purple span, .mt-shell .bento-card.card-purple b, .mt-shell .bento-card.card-orange h3, .mt-shell .bento-card.card-orange p, .mt-shell .bento-card.card-orange span, .mt-shell .bento-card.card-orange b, .mt-shell .bento-card.card-pink h3, .mt-shell .bento-card.card-pink p, .mt-shell .bento-card.card-pink span, .mt-shell .bento-card.card-pink b, .mt-shell .bento-card.card-teal h3, .mt-shell .bento-card.card-teal p, .mt-shell .bento-card.card-teal span, .mt-shell .bento-card.card-teal b, .mt-shell .bento-card.card-indigo h3, .mt-shell .bento-card.card-indigo p, .mt-shell .bento-card.card-indigo span, .mt-shell .bento-card.card-indigo b { color: var(--mt-ink) !important; }
.mt-shell .bento-card[class*="card-"] .mt-prog-txt small { color: var(--mt-muted) !important; }

/* ---------------------------------------------------------------------------
   Rich text editor (CKEditor) on every staff screen: follows light / dark.
   Before this the typing area stayed white while the text turned light in
   dark mode, so what you typed was nearly invisible.
   --------------------------------------------------------------------------- */
body.mt-shell {
    --ck-color-base-background: var(--mt-input);
    --ck-color-base-foreground: var(--mt-soft);
    --ck-color-base-border: var(--mt-line);
    --ck-color-text: var(--mt-ink);
    --ck-color-toolbar-background: var(--mt-card);
    --ck-color-toolbar-border: var(--mt-line);
    --ck-color-dropdown-panel-background: var(--mt-card);
    --ck-color-dropdown-panel-border: var(--mt-line);
    --ck-color-panel-background: var(--mt-card);
    --ck-color-panel-border: var(--mt-line);
    --ck-color-input-background: var(--mt-input);
    --ck-color-input-border: var(--mt-line);
    --ck-color-input-text: var(--mt-ink);
    --ck-color-list-background: var(--mt-card);
    --ck-color-list-button-hover-background: var(--mt-soft2);
    --ck-color-list-button-on-background: var(--mt-accent);
    --ck-color-list-button-on-text: #fff;
    --ck-color-button-default-background: transparent;
    --ck-color-button-default-hover-background: var(--mt-soft2);
    --ck-color-button-default-active-background: var(--mt-soft2);
    --ck-color-button-on-background: var(--mt-soft2);
    --ck-color-button-on-hover-background: var(--mt-soft2);
    --ck-color-button-on-color: var(--mt-ink);
    --ck-color-focus-border: var(--mt-accent);
    --ck-color-labeled-field-label-background: var(--mt-card);
    --ck-color-split-button-hover-background: var(--mt-soft2);
}
.mt-shell .ck.ck-editor__main > .ck-editor__editable,
.mt-shell .ck.ck-editor__editable.ck-editor__editable_inline,
.mt-shell .ck-content { background: var(--mt-input) !important; color: var(--mt-ink) !important; }
.mt-shell .ck.ck-editor__editable p,
.mt-shell .ck.ck-editor__editable li,
.mt-shell .ck.ck-editor__editable h1, .mt-shell .ck.ck-editor__editable h2, .mt-shell .ck.ck-editor__editable h3,
.mt-shell .ck.ck-editor__editable h4, .mt-shell .ck.ck-editor__editable blockquote,
.mt-shell .ck.ck-editor__editable td, .mt-shell .ck.ck-editor__editable th { color: inherit; }
.mt-shell .ck.ck-editor__editable a { color: var(--mt-info); }
.mt-shell .ck.ck-placeholder::before, .mt-shell .ck .ck-placeholder::before { color: var(--mt-muted) !important; }
.mt-shell .ck.ck-toolbar, .mt-shell .ck.ck-toolbar .ck-button, .mt-shell .ck.ck-toolbar .ck-dropdown__button { color: var(--mt-ink) !important; }
.mt-shell .ck.ck-icon, .mt-shell .ck.ck-icon * { color: inherit !important; }
.mt-shell .ck.ck-voice-label { display: none !important; }
