/* ============================================
   MEEM-APP — Y2K sticker theme, tuned for a tool used every day
   (same tokens as meemnotfunny.com, calmer motion, no custom cursor)
   ============================================ */

:root {
  --bg: #FDF6E3;
  --bg-alt: #FFF1D6;
  --ink: #1A1A1A;
  --ink-soft: #4A4A4A;
  --ink-muted: #7A7A7A;
  --pink: #FF3D87;
  --blue: #3D8DFF;
  --lime: #C9F76F;
  --yellow: #FFD93D;
  --purple: #B47BFF;
  --paper: #FFFFFF;
  --line: rgba(26,26,26,0.12);
  --border: 3px solid var(--ink);
  --border-thin: 2px solid var(--ink);
  --shadow-hard: 6px 6px 0 var(--ink);
  --shadow-hard-sm: 4px 4px 0 var(--ink);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 240px;
  /* chart series (validated palette, see finance.html) */
  --c1: #3D8DFF;
  --c2: #FF3D87;
  --c3: #7AB800;
  --c4: #B47BFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-weight: 900; letter-spacing: -0.3px; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.muted { color: var(--ink-muted); }
.soft { color: var(--ink-soft); }
.small { font-size: 13px; }
.bold { font-weight: 800; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* ---- App shell ---- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--paper);
  border-right: var(--border);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { font-weight: 900; font-size: 20px; display: flex; align-items: center; gap: 8px; padding: 4px 10px 18px; }
.brand .dot { width: 14px; height: 14px; background: var(--pink); border: 2px solid var(--ink); border-radius: 50%; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; font-weight: 700;
  border: 2px solid transparent;
}
.nav a:hover { background: var(--bg-alt); }
.nav a.active { background: var(--yellow); border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.nav a .ico { width: 22px; text-align: center; }
.nav .badge { margin-left: auto; }
.sidebar__foot { margin-top: auto; padding: 10px; border-top: 2px solid var(--line); font-size: 13px; }
.sidebar__foot .name { font-weight: 800; }
.main { padding: 28px 36px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--ink-soft); margin-top: 4px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.topbar-mobile { display: none; }

/* ---- Trial / plan banner ---- */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 20px;
  background: var(--lime); border: var(--border-thin); border-radius: var(--radius-sm);
  font-weight: 700;
}
.banner--warn { background: var(--yellow); }
.banner--danger { background: #FFD6E4; }
.banner .btn { margin-left: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; font-weight: 800; font-size: 14px;
  border: var(--border); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-hard-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  white-space: nowrap;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn--pink { background: var(--pink); color: #fff; }
.btn--blue { background: var(--blue); color: #fff; }
.btn--lime { background: var(--lime); }
.btn--yellow { background: var(--yellow); }
.btn--ink { background: var(--ink); color: var(--bg); }
.btn--sm { padding: 6px 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); border-width: 2px; }
.btn--sm:hover { box-shadow: 4px 4px 0 var(--ink); }
.btn--ghost { box-shadow: none; border-color: transparent; background: transparent; }
.btn--ghost:hover { box-shadow: none; transform: none; background: var(--bg-alt); }
.btn--block { width: 100%; }
.btn-spinner { width: 16px; height: 16px; border: 3px solid rgba(0,0,0,0.2); border-top-color: currentColor; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Cards / grid ---- */
.card {
  background: var(--paper); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-hard); padding: 20px;
}
.card--flat { box-shadow: none; }
.card--tint-lime { background: var(--lime); }
.card--tint-yellow { background: var(--yellow); }
.card--tint-blue { background: var(--blue); color: #fff; }
.card--tint-pink { background: var(--pink); color: #fff; }
.card--tint-purple { background: var(--purple); }
.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

/* stat tile */
.stat .stat__label { font-size: 13px; font-weight: 800; opacity: 0.8; }
.stat .stat__value { font-size: 30px; font-weight: 900; letter-spacing: -0.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .stat__sub { font-size: 13px; margin-top: 4px; opacity: 0.85; }

/* ---- Tags / badges ---- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border: 2px solid var(--ink); border-radius: 999px;
  font-weight: 800; font-size: 12px; background: var(--paper); white-space: nowrap;
}
.tag--lime { background: var(--lime); }
.tag--yellow { background: var(--yellow); }
.tag--blue { background: var(--blue); color: #fff; }
.tag--pink { background: var(--pink); color: #fff; }
.tag--purple { background: var(--purple); }
.tag--ink { background: var(--ink); color: var(--bg); }
.tag--ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.badge { display: inline-flex; min-width: 22px; height: 22px; padding: 0 7px; align-items: center; justify-content: center; border-radius: 999px; background: var(--pink); color: #fff; font-size: 12px; font-weight: 900; border: 2px solid var(--ink); }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 800; font-size: 13px; }
.label .opt { font-weight: 600; color: var(--ink-muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 14px; font-weight: 600;
  background: var(--paper); border: var(--border-thin); border-radius: var(--radius-sm);
  box-shadow: 3px 3px 0 var(--ink); transition: transform 0.1s;
}
.input:focus { outline: none; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
textarea.input { min-height: 90px; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231A1A1A' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pink); }
.error { padding: 10px 14px; background: #FFE0E0; border: 2px solid var(--pink); border-radius: 10px; color: var(--pink); font-weight: 700; font-size: 14px; }
.notice { padding: 10px 14px; background: var(--lime); border: 2px solid var(--ink); border-radius: 10px; font-weight: 700; font-size: 14px; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: var(--paper); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-hard); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 800; color: var(--ink-soft); padding: 12px 14px; border-bottom: var(--border-thin); background: var(--bg-alt); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--bg); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-muted); font-weight: 700; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---- Tabs / segmented ---- */
.seg { display: inline-flex; border: var(--border-thin); border-radius: 999px; overflow: hidden; background: var(--paper); box-shadow: 3px 3px 0 var(--ink); }
.seg button { padding: 7px 14px; font-weight: 800; font-size: 13px; background: transparent; border: 0; border-right: 2px solid var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--ink); color: var(--bg); }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(3px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-hard); padding: 26px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; position: relative; animation: pop 0.16s cubic-bezier(0.34, 1.4, 0.64, 1); }
.modal--wide { max-width: 820px; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { margin-bottom: 16px; }
.modal__close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: var(--border-thin); border-radius: 50%; background: var(--paper); font-weight: 900; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal__foot .danger { margin-right: auto; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 800; border: var(--border); z-index: 2000; transition: all 0.2s; pointer-events: none; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast--err { background: var(--pink); color: #fff; }
.toast--ok { background: var(--lime); color: var(--ink); }

/* ---- Auth pages ---- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__art { background: var(--blue); color: #fff; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; border-right: var(--border); }
.auth__art h2 { font-size: 40px; margin-top: 18px; }
.auth__form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 36px; margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink-muted); font-size: 13px; font-weight: 700; }
.divider::before, .divider::after { content: ''; flex: 1; height: 2px; background: var(--line); }
.hl { background: linear-gradient(transparent 55%, var(--yellow) 55%); padding: 0 4px; }
.hl--lime { background: linear-gradient(transparent 55%, var(--lime) 55%); }

/* ---- Job status colours ---- */
.st-inquiry { background: var(--paper); }
.st-quoted { background: var(--paper); border-style: dashed; }
.st-script { background: var(--yellow); }
.st-script_sent { background: var(--yellow); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.12) 6px 8px); }
.st-video { background: var(--purple); }
.st-video_sent { background: var(--purple); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.12) 6px 8px); }
.st-revision { background: var(--pink); color: #fff; }
.st-approved { background: var(--lime); }
.st-posted { background: var(--blue); color: #fff; }
.st-paid { background: var(--ink); color: var(--bg); }
/* Gantt phase segments */
.ph-script { background: var(--yellow); }
.ph-video { background: var(--purple); }
.ph-approved { background: var(--lime); }
.ph-posted { background: var(--blue); color: #fff; }
.gantt__bar.dim { opacity: .45; }
.st-cancelled { background: transparent; border-color: var(--line); color: var(--ink-muted); text-decoration: line-through; }
.due-late { color: var(--pink); font-weight: 900; }
.due-soon { color: #B8860B; font-weight: 800; }

/* ---- Gantt ---- */
.gantt { background: var(--paper); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-hard); overflow: hidden; }
.gantt__scroll { overflow-x: auto; }
.gantt__inner { display: grid; grid-template-columns: 270px 1fr; min-width: max-content; }
.gantt__head, .gantt__row { display: contents; }
.gantt__label { position: sticky; left: 0; z-index: 2; background: var(--paper); border-right: var(--border-thin); border-bottom: 1px solid var(--line); padding: 8px 12px; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 270px; }
.gantt__label.head { background: var(--bg-alt); border-bottom: var(--border-thin); font-size: 12px; color: var(--ink-soft); }
.gantt__label .sub { display: block; font-size: 11px; color: var(--ink-muted); font-weight: 600; }
.gantt__cells { position: relative; display: grid; grid-auto-flow: column; border-bottom: 1px solid var(--line); height: 54px; }
.gantt__cells.head { height: 40px; background: var(--bg-alt); border-bottom: var(--border-thin); }
.gantt__day { width: var(--day, 28px); border-right: 1px solid var(--line); font-size: 11px; text-align: center; color: var(--ink-muted); display: flex; flex-direction: column; justify-content: center; }
.gantt__day.weekend { background: rgba(0,0,0,0.03); }
.gantt__day.today { background: rgba(255,217,61,0.45); }
.gantt__day.month-start { border-left: 2px solid var(--ink); }
.gantt__day .m { font-weight: 800; color: var(--ink); }
.gantt__bar { position: absolute; top: 14px; height: 26px; border: 2px solid var(--ink); border-radius: 8px; font-size: 12px; font-weight: 800; padding: 0 8px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
.gantt__bar:hover { z-index: 3; box-shadow: 3px 3px 0 var(--ink); }
.gantt__mark { position: absolute; top: 11px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 12px solid var(--pink); transform: translateX(-8px); z-index: 2; }
.gantt__mark::after { content: ''; position: absolute; left: -8px; top: -14px; width: 16px; height: 12px; }

/* ---- Chart surfaces ---- */
.chart { position: relative; height: 300px; }
.chart canvas { width: 100% !important; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); vertical-align: -2px; margin-right: 6px; }

/* ---- Document (quote / invoice / receipt) print layout ---- */
.doc-page { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 48px 56px; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-hard); font-size: 14px; }
.doc-page h1 { font-size: 28px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.doc-meta { text-align: right; font-size: 13px; }
.doc-meta b { display: inline-block; min-width: 90px; text-align: left; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; font-size: 13px; }
.doc-parties h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #777; margin-bottom: 6px; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.doc-table th { text-align: left; font-size: 12px; padding: 8px 10px; border-top: 2px solid #111; border-bottom: 2px solid #111; }
.doc-table td { padding: 9px 10px; border-bottom: 1px solid #ddd; vertical-align: top; }
.doc-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-totals { margin-left: auto; width: 320px; font-size: 14px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 5px 10px; }
.doc-totals .grand { border-top: 2px solid #111; border-bottom: 2px solid #111; font-weight: 900; font-size: 17px; margin-top: 6px; }
.doc-foot { margin-top: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: 13px; }
.doc-foot h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #777; margin-bottom: 6px; }
.doc-sign { margin-top: 48px; text-align: center; }
.doc-sign .line { border-top: 1px solid #111; width: 220px; margin: 48px auto 6px; }
.doc-stamp { display: inline-block; padding: 4px 12px; border: 3px solid; border-radius: 8px; font-weight: 900; transform: rotate(-6deg); letter-spacing: 0.06em; }
.doc-stamp--paid { color: #1a8f3a; border-color: #1a8f3a; }
.doc-stamp--void { color: #c0392b; border-color: #c0392b; }
.doc-stamp--draft { color: #888; border-color: #888; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .doc-page { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* ---- Public intake page ---- */
.public { max-width: 640px; margin: 0 auto; padding: 40px 20px 80px; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth__art { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform 0.2s; z-index: 500; box-shadow: var(--shadow-hard); }
  .sidebar.open { transform: translateX(0); }
  .topbar-mobile { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--paper); border-bottom: var(--border); position: sticky; top: 0; z-index: 400; }
  .main { padding: 18px 16px 60px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  h1 { font-size: 24px; }
  .gantt__inner { grid-template-columns: 140px 1fr; }
  .gantt__label { max-width: 140px; padding: 6px 8px; font-size: 12px; }
  .doc-page { padding: 24px 18px; }
  .doc-parties, .doc-foot { grid-template-columns: 1fr; }
  .doc-totals { width: 100%; }
}
