/* ============================================================
   MTOS — MC3 Tech Labs Operating System
   Charcoal + Gold, Inter, dark-first admin UI.
   ============================================================ */
:root {
  --c900: #14161B;
  --c800: #1A1C22;
  --c700: #23262D;
  --c600: #2F333D;
  --gold: #C8A84B;
  --gold-2: #D4B85E;
  --gold-dim: rgba(200, 168, 75, 0.12);
  --gold-line: rgba(200, 168, 75, 0.28);
  --ink: #FAFAFA;
  --muted: #A1A1AA;
  --muted-2: #71717A;
  --line: #2F333D;
  --line-soft: rgba(255, 255, 255, 0.07);
  --ok: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --purple: #8B5CF6;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--c900); color: var(--ink); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1,h2,h3,h4 { line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .9rem; color: var(--muted); }
strong { color: var(--ink); }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 272px; flex: 0 0 272px; background: var(--c800); border-right: 1px solid var(--line-soft);
  height: 100vh; position: sticky; top: 0; overflow-y: auto; padding: 18px 14px 40px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; }
.sidebar .brand img { height: 40px; width: auto; }
.sidebar .brand small { display: block; font-size: .68rem; color: var(--muted-2); letter-spacing: .12em; text-transform: uppercase; }
.group-label { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: rgba(200,168,75,.85); margin: 18px 10px 8px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.group-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-line), transparent); }
.nav-section > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; font-size: .86rem; font-weight: 600; color: var(--muted); }
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary:hover { background: var(--c700); color: var(--ink); }
.nav-section[open] > summary { color: var(--ink); }
.nav-section > summary .emoji { font-size: .95rem; }
.nav-section ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 12px; }
.nav-section li a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; font-size: .8rem; color: var(--muted); }
.nav-section li a:hover { background: var(--c700); color: var(--ink); }
.nav-section li a.active { background: var(--gold-dim); color: var(--gold-2); }

.main { flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(20,22,27,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); padding: 12px 26px; display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.search { display: flex; align-items: center; gap: 8px; background: var(--c700); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; flex: 1; max-width: 460px; }
.search input { background: none; border: none; color: var(--ink); outline: none; font: inherit; width: 100%; }
.search i { color: var(--muted-2); }
.content { padding: 30px 26px 70px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head .badge { display: inline-block; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); background: var(--gold-dim); border: 1px solid var(--gold-line); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.page-head p { max-width: 70ch; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2,1fr); }
.g3 { grid-template-columns: repeat(3,1fr); }
.g4 { grid-template-columns: repeat(4,1fr); }
.card { background: var(--c700); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.flat { background: var(--c800); }
.card h3 { margin-bottom: .5rem; }
.card p:last-child { margin-bottom: 0; }
.section { margin-bottom: 34px; }
.section > h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section > h2::before { content: ''; width: 4px; height: 20px; background: var(--gold); border-radius: 2px; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); }
.kpi .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; }
.kpi .value.gold { color: var(--gold); }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.trend { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.trend.up { background: rgba(16,185,129,.14); color: #6EE7B7; }
.trend.down { background: rgba(239,68,68,.14); color: #FCA5A5; }

/* ---------- Pills / status ---------- */
.pill { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; background: var(--c600); color: var(--muted); }
.pill.gold { background: var(--gold-dim); color: var(--gold-2); border: 1px solid var(--gold-line); }
.pill.ok { background: rgba(16,185,129,.14); color: #6EE7B7; }
.pill.warn { background: rgba(245,158,11,.14); color: #FCD34D; }
.pill.danger { background: rgba(239,68,68,.14); color: #FCA5A5; }
.pill.info { background: rgba(59,130,246,.14); color: #93C5FD; }
.pill.purple { background: rgba(139,92,246,.14); color: #C4B5FD; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-family: var(--font); font-size: .85rem; font-weight: 600; padding: 0 15px; min-height: 40px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; transition: .15s ease; }
.btn-primary { background: var(--gold); color: #16181D; }
.btn-primary:hover { background: var(--gold-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-2); }
.btn-danger { background: rgba(239,68,68,.14); color: #FCA5A5; border-color: rgba(239,68,68,.35); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: .78rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; font-family: var(--font); font-size: .9rem; color: var(--ink); background: var(--c900); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.row { display: grid; gap: 14px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
tr:hover td { background: rgba(255,255,255,.015); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(900px 500px at 50% -10%, rgba(200,168,75,.10), transparent), var(--c900); }
.login-card { width: 100%; max-width: 400px; background: var(--c800); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.login-card img { height: 56px; margin: 0 auto 18px; }
.login-card h1 { text-align: center; font-size: 1.35rem; }
.login-card p { text-align: center; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mt-0 { margin-top: 0 } .mt-2 { margin-top: 14px } .mt-3 { margin-top: 22px }
.mb-0 { margin-bottom: 0 }
.flex { display: flex; } .between { justify-content: space-between } .items-center { align-items: center }
.gap { gap: 12px } .wrap { flex-wrap: wrap }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: flex-start; }
.list li:last-child { border-bottom: none; }
.check { color: var(--gold); margin-top: 4px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted-2); border: 1px dashed var(--line); border-radius: var(--radius); }
.bar { height: 8px; background: var(--c900); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.divider { height: 1px; background: var(--line-soft); margin: 22px 0; border: 0; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--c700); border: 1px solid var(--gold-line); color: var(--ink); padding: 12px 16px; border-radius: 10px; font-size: .85rem; box-shadow: 0 20px 50px rgba(0,0,0,.5); z-index: 100; display: none; }
.toast.show { display: block; }
dialog { border: 1px solid var(--line); background: var(--c800); color: var(--ink); border-radius: 14px; padding: 0; max-width: 640px; width: calc(100vw - 40px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog .dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-body { padding: 20px; max-height: 66vh; overflow-y: auto; }
dialog .dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.burger { display: none; background: none; border: 1px solid var(--line); color: var(--ink); width: 38px; height: 38px; border-radius: 9px; cursor: pointer; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; gap: 4px; background: var(--c800); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.seg .btn { min-height: 30px; }

/* ---------- Kanban board ---------- */
.kb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: var(--c800); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px; min-height: 140px; display: flex; flex-direction: column; }
.kb-col.drop { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-line); }
.kb-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kb-col-head h3 { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.kb-count { font-size: .7rem; font-weight: 700; color: var(--gold-2); background: var(--gold-dim); border-radius: 999px; padding: 2px 8px; }
.kb-cards { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.kb-card { background: var(--c700); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: grab; transition: .12s ease; }
.kb-card:hover { border-color: var(--gold-line); transform: translateY(-1px); }
.kb-card.dragging { opacity: .45; }
.kb-card h4 { margin: 0 0 4px; font-size: .92rem; }
.kb-card .meta { font-size: .74rem; color: var(--muted-2); margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
.kb-move { display: flex; gap: 4px; margin-top: 10px; }
.kb-move button { flex: 1; font-size: .68rem; min-height: 26px; padding: 0 6px; }

/* ---------- Tabs (project detail) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .85rem; padding: 10px 14px; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--gold-2); border-bottom-color: var(--gold); }
.tab .n { font-size: .68rem; background: var(--c600); border-radius: 999px; padding: 1px 7px; margin-left: 6px; color: var(--muted); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Milestones / timeline ---------- */
.ms { position: relative; padding-left: 26px; }
.ms::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.ms-item { position: relative; padding: 0 0 18px; }
.ms-item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c800); border: 2px solid var(--muted-2); }
.ms-item.done::before { background: var(--gold); border-color: var(--gold); }
.ms-item.prog::before { border-color: var(--info); background: var(--info); }
.ms-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ms-head strong { font-size: .9rem; }
.ms-date { font-size: .74rem; color: var(--muted-2); }
.ms-item .small { margin-top: 4px; }

/* ---------- Activity feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.feed li:last-child { border-bottom: none; }
.feed .dot { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: grid; place-items: center; background: var(--c600); color: var(--gold-2); font-size: .74rem; }
.feed .body { flex: 1; min-width: 0; }
.feed .body .when { font-size: .72rem; color: var(--muted-2); }
.feed .who { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-left: 6px; }
.feed .who.client { color: var(--info); }
.feed .who.mc3 { color: var(--gold-2); }

/* ---------- Chat / messages ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 10px 13px; border-radius: 12px; font-size: .86rem; line-height: 1.45; }
.bubble.client { align-self: flex-start; background: var(--c600); border-bottom-left-radius: 3px; }
.bubble.mc3 { align-self: flex-end; background: var(--gold-dim); border: 1px solid var(--gold-line); border-bottom-right-radius: 3px; }
.bubble .meta { display: block; font-size: .68rem; color: var(--muted-2); margin-top: 5px; }
.chat-form { display: flex; gap: 8px; margin-top: 14px; }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 140px; font-family: var(--font); font-size: .9rem; color: var(--ink); background: var(--c900); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; resize: vertical; }

/* ---------- Client portal (public) ---------- */
.portal { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(1000px 520px at 50% -8%, rgba(200,168,75,.10), transparent), var(--c900); }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 26px; border-bottom: 1px solid var(--line-soft); }
.portal-brand img { height: 38px; width: auto; }
.portal-badge { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); background: var(--gold-dim); border: 1px solid var(--gold-line); padding: 5px 12px; border-radius: 999px; }
.portal-main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 30px 26px 60px; }
.portal-foot { border-top: 1px solid var(--line-soft); padding: 18px 26px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .78rem; color: var(--muted-2); }
.portal-foot a { color: var(--gold-2); }
.p-welcome { background: var(--gold-dim); border: 1px solid var(--gold-line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px; }
.p-welcome h2 { margin-bottom: 4px; }
.p-proj { margin-bottom: 18px; }
.p-proj .p-phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.p-proj .p-phead h3 { margin: 0; }
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 14px; }
.tile { background: var(--c800); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; }
.tile .lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-2); }
.tile .val { font-size: 1.15rem; font-weight: 700; }
.privacy-note { font-size: .74rem; color: var(--muted-2); margin-top: 10px; }

@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2,1fr); }
  .g3 { grid-template-columns: repeat(2,1fr); }
  .burger { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar { position: fixed; z-index: 50; left: -290px; transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 0 0 60px rgba(0,0,0,.6); }
}
@media (max-width: 620px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .row.c2, .row.c3 { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 60px; }
  .portal-main { padding: 20px 16px 50px; }
}
