/* M-Tech Platform console: one stylesheet for every page (tokens, shell, components). Dark by default, as the twins;
   light with <html data-theme="light"> or the OS preference when the user hasn't chosen. */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #08121c; --panel: #0e1a26; --card: #13212f; --card2: #182a3b; --line: #213446; --line2: #2b4258;
  --text: #e6eef5; --dim: #97a9ba; --faint: #627689; --accent: #2ec4b6; --accent2: #39d0d8; --on-accent: #04201d;
  --good: #4ade80; --warn: #f5b84b; --bad: #ff6b6b; --info: #7aa7ff; --purple: #b794f6;
  --wash: color-mix(in srgb, var(--accent) 10%, transparent); --wash2: color-mix(in srgb, var(--accent) 18%, transparent);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45); --r: 12px; --r2: 9px; --r3: 6px;
  --ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --nav: 220px; --top: 56px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f6f9; --panel: #ffffff; --card: #f7f9fb; --card2: #eef3f7; --line: #dfe7ee; --line2: #cfdbe5;
  --text: #0f2233; --dim: #4d6378; --faint: #8296a8; --accent: #0f9d91; --accent2: #12a9b3; --on-accent: #ffffff;
  --good: #15994a; --warn: #b7791f; --bad: #d64545; --info: #3b6fd8; --purple: #7c4dcc; --shadow: 0 10px 30px rgba(15, 34, 51, .12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--dim); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.mono, code, kbd { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); } .faint { color: var(--faint); } .good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- shell */
.mt-top { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 40; }
.mt-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; }
.mt-brand i { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #1b6f9c); display: grid; place-items: center; font-style: normal; font-size: 13px; color: #fff; font-weight: 700; }
.mt-marina { display: flex; align-items: center; gap: 8px; }
.mt-marina select { min-width: 220px; }
.mt-top .grow { flex: 1; }
.mt-search { width: min(360px, 32vw); }
.mt-user { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.mt-nav { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--nav); padding: 12px 10px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; z-index: 30; }
.mt-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r2); color: var(--dim); font-weight: 500; text-decoration: none; }
.mt-nav a:hover { background: var(--card); color: var(--text); }
.mt-nav a.on { background: var(--wash2); color: var(--accent); }
.mt-nav a .ic { width: 18px; height: 18px; flex: none; }
.mt-nav a .badge { margin-left: auto; }
.mt-nav a.off { opacity: .55; } .mt-nav a .tag { margin-left: auto; font-size: 10px; }
body.contractor .mt-search { display: none; }
.mt-nav .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.mt-nav .lbl { padding: 10px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.mt-main { margin: var(--top) 0 0 var(--nav); padding: 20px 24px 60px; min-height: calc(100vh - var(--top)); }
.mt-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.mt-head .sub { color: var(--dim); margin-top: 3px; }
.mt-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
body.embed .mt-top, body.embed .mt-nav { display: none; }
body.embed .mt-main { margin: 0; padding: 14px 16px 40px; }
@media (max-width: 900px) {
  :root { --nav: 0px; }
  .mt-nav { transform: translateX(-100%); width: 240px; transition: transform .2s; }
  body.nav-open .mt-nav { transform: none; box-shadow: var(--shadow); }
  .mt-search { display: none; }
  .mt-main { padding: 16px 16px 60px; }
}
.mt-burger { display: none; } @media (max-width: 900px) { .mt-burger { display: inline-flex; } }

/* ---------------------------------------------------------------- controls */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r2); border: 1px solid var(--line2); background: var(--card); color: var(--text); font: 500 13.5px var(--ui); cursor: pointer; white-space: nowrap; text-decoration: none; }
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
button.pri, .btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.pri:hover:not(:disabled) { filter: brightness(1.08); color: var(--on-accent); }
button.danger { color: var(--bad); } button.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
button.ghost { background: none; border-color: transparent; color: var(--dim); } button.ghost:hover:not(:disabled) { background: var(--card); color: var(--text); border-color: transparent; }
button.sm, .btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
button.icon { width: 34px; padding: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { height: 34px; padding: 0 10px; border-radius: var(--r2); border: 1px solid var(--line2); background: var(--bg); color: var(--text); font: 400 13.5px var(--ui); min-width: 0; }
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--wash); }
input[type="checkbox"], input[type="radio"] { height: auto; accent-color: var(--accent); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--dim); font-weight: 500; }
label.f > span { display: flex; justify-content: space-between; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.form .wide { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.seg button { height: 28px; border: 0; background: none; color: var(--dim); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flat { background: var(--card); }
.card > h3, .card > .h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card > .h .actions { margin-left: auto; display: flex; gap: 6px; }
.grid { display: grid; gap: 14px; }
.grid.k { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .l { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.kpi .d { font-size: 12px; margin-top: 6px; color: var(--faint); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--dim)) 14%, transparent); color: var(--c, var(--dim)); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.tag { display: inline-flex; height: 20px; padding: 0 7px; align-items: center; border-radius: 5px; background: var(--card2); color: var(--dim); font-size: 11.5px; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--c, var(--faint)); }
.dot.live { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--good)) 60%, transparent); } 60% { box-shadow: 0 0 0 6px transparent; } }
.empty { padding: 34px 16px; text-align: center; color: var(--dim); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.err { color: var(--bad); }
.skeleton { background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; min-height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { position: sticky; top: 0; background: var(--panel); text-align: left; font-size: 12px; font-weight: 600; color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; }
.tbl th.sort { cursor: pointer; } .tbl th.sort:hover { color: var(--text); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--card); }
.tbl tbody tr.click { cursor: pointer; }
.tbl td.r, .tbl th.r { text-align: right; }

/* ---------------------------------------------------------------- overlays */
.mt-drawer-bg { position: fixed; inset: 0; background: rgba(2, 8, 14, .5); z-index: 60; opacity: 0; transition: opacity .18s; }
.mt-drawer-bg.on { opacity: 1; }
.mt-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 61;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; }
.mt-drawer.wide { width: min(860px, 100vw); }
.mt-drawer.on { transform: none; }
.mt-drawer > header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mt-drawer > header h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-drawer > .body { flex: 1; overflow-y: auto; padding: 16px 18px 30px; }
.mt-drawer > footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.mt-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(2, 8, 14, .55); padding: 16px; }
.mt-modal > div { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; }
.mt-modal h2 { margin-bottom: 10px; }
.mt-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 90; background: var(--card2); color: var(--text); border: 1px solid var(--line2);
  border-radius: 10px; padding: 10px 16px; box-shadow: var(--shadow); transition: all .2s; max-width: min(560px, calc(100vw - 32px)); }
.mt-toast.on { opacity: 1; transform: translate(-50%, 0); }
.mt-toast { pointer-events: none; }
.mt-toast.bad { border-color: var(--bad); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { height: 36px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--dim); padding: 0 12px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover:not(.on) { color: var(--text); border-color: transparent transparent var(--line2); }

/* ---------------------------------------------------------------- timeline, board */
.timeline { display: flex; flex-direction: column; }
.timeline .it { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 8px 0; }
.timeline .it .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); color: var(--dim); font-size: 13px; }
.timeline .it .meta { font-size: 12px; color: var(--faint); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board .col { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.board .col > header { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 2px 4px 6px; }
.board .col > header small { color: var(--faint); font-weight: 500; margin-left: auto; }
.board .col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.board .item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 11px; cursor: grab; }
.board .item:hover { border-color: var(--line2); }
.board .item.drag { opacity: .5; }
