:root{
  color-scheme: light;
  --surface-1:#fcfcfb; --plane:#f9f9f7;
  --text-primary:#0b0b0b; --text-secondary:#52514e; --muted:#898781;
  --grid:#e1e0d9; --axis:#c3c2b7; --ring:rgba(11,11,11,0.15);
  
  /* Q-Track-Prototype status colors */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100; --s5:#e87ba4;
  --good:#0ca30c; --warning:#fab219; --serious:#ec835a; --critical:#d03b3b;
  
  /* AppsScript_Index master plan colors */
  --navy:#1F3864; --navy2: #2C4C7C;
  --p1:#0E7490; --p2:#7030A0; --p3:#B26500; --p4:#2E5C8A; --p5:#9B2C6F; --p6:#2F6F4F;
  --red:#C00000; --green:#2E7D32; --grey:#595959;

  --radius:10px;
  --shadow: 0 1px 3px rgba(20,30,60,.08), 0 6px 20px rgba(20,30,60,.06);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--text-primary);
  font-family: system-ui,-apple-system,"Segoe UI","Leelawadee UI","Noto Sans Thai",sans-serif;
  font-size: 14px; line-height: 1.6;
}

/* ── กรอบจอ (Layout) ── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: var(--plane); }
.side { background: var(--surface-1); border-right: 1px solid var(--ring); padding: 18px 0; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.main { padding: 20px 24px 60px; min-width: 0; }
@media(max-width:1000px) { .app { grid-template-columns: 1fr; } .side { display: none; } }

/* ── Sidebar ── */
.brand { padding: 0 18px 16px; border-bottom: 1px solid var(--ring); margin-bottom: 12px; }
.brand b { display: block; color: var(--navy); font-size: 16px; font-weight: 700; }
.brand span { color: var(--muted); font-size: 12.5px; }
.nav a { display: block; padding: 10px 18px; color: var(--text-secondary); text-decoration: none; font-size: 14px; border-left: 3px solid transparent; display:flex; align-items:center; gap:8px;}
.nav a:hover { color: var(--navy); background: var(--plane); }
.nav a.on { background: var(--plane); color: var(--navy); font-weight: 600; border-left-color: var(--navy); }
.nav a i { font-size:15px; width:18px; text-align:center;}
.nav .grp { padding: 14px 18px 5px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px; }

/* ── Typography ── */
h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -.02em;}
.lede { color: var(--text-secondary); font-size: 14px; margin: 0 0 20px; }
h2 { font-size: 16px; font-weight: 600; margin: 26px 0 11px; color: var(--text-primary); letter-spacing: -.01em;}
h2:first-of-type { margin-top: 0; }
h3 { margin: 0 0 2px; font-size: 14.5px; letter-spacing: -.01em; color: var(--text-primary); }

/* ── UI Elements from Prototype ── */
.card { background: var(--surface-1); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px 18px; margin-top: 14px; }
.card .cap { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 14px; }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g2 { grid-template-columns: 1.35fr 1fr; }
.g2e { grid-template-columns: 1fr 1fr; }
@media(max-width:980px) { .g5 { grid-template-columns: repeat(2, 1fr); } .g2, .g2e { grid-template-columns: 1fr; } }

.tile { background: var(--surface-1); border: 1px solid var(--ring); border-radius: var(--radius); padding: 14px 16px; }
.tile .lbl { color: var(--text-secondary); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.tile .val { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.tile .foot { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--ring); color: var(--text-secondary); background: var(--plane); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--ring); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--plane); border: 1px solid var(--ring); color: var(--text-secondary); white-space: nowrap; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:hover { background: var(--plane); }
.scroll { overflow: auto; max-height: 520px; }

/* ── Work Items / Lists ── */
.wi { border: 1px solid var(--ring); border-radius: 9px; padding: 11px 13px; margin-bottom: 8px; background: var(--surface-1); display: flex; gap: 12px; align-items: flex-start; }
.wi .stripe { width: 4px; border-radius: 3px; align-self: stretch; flex: none; }
.wi h4 { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; }
.wi .meta { color: var(--muted); font-size: 11.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.wi:hover { background: var(--plane); cursor:pointer; }
.wi a { text-decoration:none; color:inherit; display:flex; gap:12px; width:100%; }

/* ── Buttons & Inputs ── */
.btn { border: 0; background: var(--navy); color: #fff; font-family: inherit; font-size: 12.5px; padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight:600; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.btn.gr { background: var(--good); }
.btn.red { background: var(--critical); color:#fff; }
.btn:hover { opacity:0.9; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
select, input[type=search], input[type=text], textarea { font-family: inherit; font-size: 13px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--ring); background: var(--surface-1); color: var(--text-primary); }
textarea { min-height: 60px; resize: vertical; }
label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; display:block; font-weight:600; }

.note { background: var(--plane); border: 1px dashed var(--axis); border-radius: 9px; padding: 12px 14px; color: var(--text-secondary); font-size: 12.5px; margin-top: 14px; }
.note b { color: var(--text-primary); }

/* ── Timeline specific classes from appscript_index ── */
.tl { overflow-x: auto; border: 1px solid var(--ring); border-radius: 6px; background:var(--surface-1); }
.tl-grid { min-width: 1200px; }
.tl-hdr { display: grid; position: sticky; top: 0; z-index: 5; background: var(--surface-1); }
.tl-hdr div { font-size: 11px; text-align: center; padding: 2px 0; border-right: 1px solid var(--grid); line-height: 1.15; border-bottom:1px solid var(--axis); }
.tl-hdr .fy { color: var(--text-primary); font-weight: 700; font-size: 12px; background:var(--plane); }
.tl-lane { display: grid; border-top: 1px solid var(--grid); position:relative; }
.tl-row { position: relative; height: 26px; }
.tl-chip { position: absolute; top: 2px; height: 22px; border-radius: 4px; color: #fff; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: flex-start; padding: 0 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; border: 1px solid rgba(0,0,0,.12); }
.tl-chip:hover { outline: 2px solid var(--navy); outline-offset: 1px; }

/* ── Utilities ── */
.hidden { display: none !important; }
.text-critical { color: var(--critical); }
.text-warning { color: var(--warning); }
.text-serious { color: var(--serious); }
.text-good { color: var(--good); }
.text-muted { color: var(--muted); }
.bg-critical { background-color: var(--critical); }
.bg-warning { background-color: var(--warning); }
.bg-serious { background-color: var(--serious); }
.bg-good { background-color: var(--good); }
