/* ZaloTask — retro desktop theme. Paper + ink, chunky borders, offset shadows. */
:root {
  --paper: #f3ead7;
  --paper-2: #ebdfc4;
  --card: #fffaf0;
  --ink: #23201a;
  --muted: #6f6656;
  --line: #23201a;
  --shadow: #23201a;

  --mustard: #f2b134;
  --tomato: #e4572e;
  --blue: #3a6ea5;
  --green: #4c956c;
  --teal: #2a9d8f;
  --plum: #8e6c8a;
  --violet: #6d5bd0;

  --oktravel: var(--teal);
  --amamy: var(--green);
  --le: var(--plum);
  --open: var(--mustard);
  --doing: var(--blue);
  --done: var(--green);
  --ignored: #a39a88;

  --r: 10px;
  --bw: 2px;
  --sh: 4px 4px 0 var(--shadow);
  --sh-sm: 2px 2px 0 var(--shadow);
  --font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --pixel: "VT323", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d1b17;
    --paper-2: #26231d;
    --card: #2b2721;
    --ink: #f1e7d0;
    --muted: #b2a790;
    --line: #8c826d;
    --shadow: #000;
    --ignored: #7d7565;
  }
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--font);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 18px 18px,
    var(--paper);
  min-height: 100vh;
}
a { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
small { font-size: .8em; }
[hidden] { display: none !important; }

/* ---------- title bar ---------- */
.titlebar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card); border-bottom: var(--bw) solid var(--line);
  box-shadow: 0 3px 0 var(--shadow);
}
.titlebar .bar { display: flex; align-items: center; gap: 22px; height: 60px; }
.brand { font: 30px/1 var(--pixel); letter-spacing: 1px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--tomato); font-weight: normal; }
.brand .logo {
  display: grid; place-items: center; width: 30px; height: 30px; font: 700 18px/1 var(--font);
  background: var(--mustard); color: #23201a; border: var(--bw) solid var(--line); border-radius: 7px; box-shadow: var(--sh-sm);
}
.tabs { display: flex; gap: 6px; flex: 1; }
.tabs a {
  text-decoration: none; font-weight: 600; padding: 6px 14px; border-radius: 8px;
  border: var(--bw) solid transparent; color: var(--muted);
}
.tabs a:hover { color: var(--ink); border-color: var(--line); }
.tabs a.active { color: #23201a; background: var(--mustard); border-color: var(--line); box-shadow: var(--sh-sm); }
.scan { display: flex; align-items: center; gap: 12px; }
.led-text { display: inline-flex; align-items: center; gap: 7px; font: 19px/1 var(--pixel); color: var(--muted); }
.led { width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 1.5px solid var(--line); }
.led.busy { background: var(--mustard); animation: blink .8s steps(2) infinite; }
.led.err { background: var(--tomato); }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- buttons & inputs ---------- */
.btn, .chip, .seg button {
  font: 600 14px/1 var(--font); color: var(--ink); background: var(--card);
  border: var(--bw) solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer;
  box-shadow: var(--sh-sm); transition: transform .05s, box-shadow .05s;
}
.btn:hover, .chip:hover, .seg button:hover { background: var(--paper-2); }
.btn:active, .chip:active, .seg button:active { transform: translate(2px, 2px); box-shadow: none; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.primary { background: var(--tomato); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--tomato) 88%, #000); }
.btn.danger { color: var(--tomato); }
.btn.sm { padding: 5px 9px; font-size: 13px; }

input, select, textarea {
  font: 500 14px/1.3 var(--font); color: var(--ink); background: var(--card);
  border: var(--bw) solid var(--line); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--mustard) 70%, transparent); outline-offset: 0; }
textarea { resize: vertical; width: 100%; }

/* ---------- windows ---------- */
.window { background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.window-title {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 12px; font: 22px/1.1 var(--pixel); letter-spacing: .5px;
  border-bottom: var(--bw) solid var(--line);
  background: repeating-linear-gradient(0deg, var(--paper-2) 0 2px, var(--card) 2px 4px);
}
.window-title a { font: 600 13px var(--font); color: var(--muted); text-decoration: none; }
.window-title a:hover { color: var(--ink); }
.window-body { padding: 12px; }
.window-foot { display: flex; gap: 8px; align-items: center; padding: 12px; border-top: var(--bw) solid var(--line); background: var(--paper-2); }
.spacer { flex: 1; }

/* ---------- dashboard ---------- */
main { padding: 26px 20px 60px; }
.hello h1 { font: 44px/1 var(--pixel); margin: 0 0 4px; }
.hello p { margin: 0 0 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 26px; }
.tile {
  background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--sh);
  padding: 14px 16px 12px; cursor: pointer; position: relative; text-decoration: none; display: block;
  transition: transform .08s, box-shadow .08s;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.tile .n { font: 58px/0.9 var(--pixel); }
.tile .l { font-weight: 600; font-size: 13.5px; margin-top: 6px; }
.tile .ico { position: absolute; top: 10px; right: 12px; font-size: 20px; opacity: .9; }
.tile.mustard { background: var(--mustard); color: #23201a; }
.tile.tomato { background: var(--tomato); color: #fff; }
.tile.blue { background: var(--blue); color: #fff; }
.tile.green { background: var(--green); color: #fff; }
.tile.violet { background: var(--violet); color: #fff; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }

.list-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 9px 4px; border-bottom: 1.5px dashed color-mix(in srgb, var(--line) 40%, transparent); cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover .t { text-decoration: underline; }
.list-item .t { font-weight: 600; }
.list-item .s { color: var(--muted); font-size: 12.5px; }

.bar-row { display: grid; grid-template-columns: 82px 1fr 34px; gap: 10px; align-items: center; margin: 8px 0; text-decoration: none; }
.bar-row .track { height: 18px; border: var(--bw) solid var(--line); border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.bar-row .fill { height: 100%; background-image: repeating-linear-gradient(90deg, currentColor 0 8px, transparent 8px 10px); }
.bar-row .num { font: 24px/1 var(--pixel); text-align: right; }
.bar-row .name { font-weight: 600; }
.chat-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px; border-bottom: 1.5px dashed color-mix(in srgb, var(--line) 30%, transparent); }
.chat-row:last-child { border-bottom: 0; }
.chat-row b { font: 22px/1 var(--pixel); }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }

/* ---------- badges & chips ---------- */
.tag {
  display: inline-block; font: 700 11px/1 var(--font); letter-spacing: .4px; text-transform: uppercase;
  padding: 4px 7px; border-radius: 5px; border: 1.5px solid var(--line); white-space: nowrap; color: #fff;
}
.tag.oktravel { background: var(--oktravel); }
.tag.amamy { background: var(--amamy); }
.tag.le { background: var(--le); }
.tag.high { background: var(--tomato); }
.tag.open { background: var(--mustard); color: #23201a; }
.tag.doing { background: var(--blue); }
.tag.done { background: var(--green); }
.tag.ignored { background: var(--ignored); }
.due { display: inline-flex; gap: 4px; align-items: center; font: 600 12.5px/1 var(--font); padding: 4px 7px; border-radius: 5px; border: 1.5px solid var(--line); background: var(--card); white-space: nowrap; }
.due.overdue { background: var(--tomato); color: #fff; }
.due.today { background: var(--mustard); color: #23201a; }

.chips { display: flex; gap: 6px; }
.chip { padding: 8px 12px; }
.chip.active { background: var(--ink); color: var(--paper); }
.chip.oktravel.active { background: var(--oktravel); color: #fff; }
.chip.amamy.active { background: var(--amamy); color: #fff; }
.chip.le.active { background: var(--le); color: #fff; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; box-shadow: none; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.seg button.active { background: var(--ink); color: var(--paper); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.toolbar #q { flex: 1; min-width: 220px; }
.toolbar #add-btn { margin-left: auto; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.col { background: color-mix(in srgb, var(--paper-2) 70%, transparent); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--sh); min-height: 220px; display: flex; flex-direction: column; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: var(--bw) solid var(--line); border-radius: calc(var(--r) - 2px) calc(var(--r) - 2px) 0 0; font: 26px/1 var(--pixel); }
.col-head.open { background: var(--mustard); color: #23201a; }
.col-head.doing { background: var(--blue); color: #fff; }
.col-head.done { background: var(--green); color: #fff; }
.col-head .count { font: 26px/1 var(--pixel); background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 6px; padding: 1px 8px; }
.col-body { padding: 12px; display: grid; gap: 12px; align-content: start; flex: 1; min-height: 160px; }
.col.drop-over { outline: 3px dashed var(--tomato); outline-offset: 3px; }

.card {
  background: var(--card); border: var(--bw) solid var(--line); border-radius: 9px; box-shadow: var(--sh-sm);
  padding: 10px 12px 10px 16px; cursor: grab; position: relative; overflow: hidden;
  transition: transform .06s, box-shadow .06s;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--c, var(--line)); border-right: 1.5px solid var(--line); }
.card.oktravel { --c: var(--oktravel); }
.card.amamy { --c: var(--amamy); }
.card.le { --c: var(--le); }
.card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.card.dragging { opacity: .45; }
.card.is-overdue { background: color-mix(in srgb, var(--tomato) 12%, var(--card)); }
.card .top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.card .id { margin-left: auto; font: 17px/1 var(--pixel); color: var(--muted); }
.card .title { font-weight: 600; line-height: 1.38; }
.card .detail { color: var(--muted); font-size: 13px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.card .foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .quick { position: absolute; right: 8px; bottom: 8px; display: none; gap: 4px; }
.card:hover .quick { display: flex; }
.card .quick button { font-size: 12px; padding: 3px 7px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); cursor: pointer; }
.card .quick button:hover { background: var(--mustard); color: #23201a; }
.done-col .card .title { text-decoration: line-through; color: var(--muted); }

.hint { margin: 14px 2px 8px; font-size: 13px; }
.dropbin {
  margin-top: 6px; padding: 12px; text-align: center; border: var(--bw) dashed var(--line); border-radius: var(--r);
  color: var(--muted); display: none;
}
body.dragging-card .dropbin { display: block; }
.dropbin.drop-over { background: var(--ignored); color: #fff; }

/* ---------- table ---------- */
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1.5px dashed color-mix(in srgb, var(--line) 35%, transparent); vertical-align: top; }
th { font: 20px/1 var(--pixel); color: var(--muted); font-weight: normal; border-bottom: var(--bw) solid var(--line); }
tbody tr:hover { background: color-mix(in srgb, var(--mustard) 12%, transparent); cursor: pointer; }
tbody tr.is-overdue { background: color-mix(in srgb, var(--tomato) 10%, transparent); }
tbody tr.is-done td.t { text-decoration: line-through; color: var(--muted); }
td.t b { font-weight: 600; }
td .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
td.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 4px; }

/* ---------- dialog ---------- */
dialog.window { padding: 0; width: min(620px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: color-mix(in srgb, #23201a 45%, transparent); backdrop-filter: blur(1px); }
dialog .x { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.meta { font-size: 12.5px; color: var(--muted); }
.meta blockquote { margin: 6px 0 0; padding: 8px 10px; border: 1.5px dashed var(--line); border-radius: 7px; white-space: pre-line; background: var(--paper-2); color: var(--ink); max-height: 160px; overflow: auto; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px;
  border: var(--bw) solid var(--line); box-shadow: var(--sh); font-weight: 600;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .scan .led-text { display: none; }
}
@media (max-width: 600px) {
  .titlebar .bar { gap: 10px; }
  .brand { font-size: 24px; }
  .tabs a { padding: 6px 9px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar #add-btn { margin-left: 0; }
}
.list-item > .tag:first-child, td > .tag:first-child { min-width: 84px; text-align: center; }

/* Cancel ("Huỷ task") — muted grey-red so it reads as "stop", distinct from delete. */
.btn.cancel { color: var(--muted); }
.btn.cancel:hover { background: var(--ignored); color: #fff; }
.card .quick button.cancel:hover { background: var(--ignored); color: #fff; }
.dropbin.drop-over { background: var(--ignored); }

/* ---------- selection ---------- */
label.pick { display: inline-flex; align-items: center; cursor: pointer; margin-right: 2px; }
label.pick input { width: 17px; height: 17px; margin: 0; accent-color: var(--tomato); cursor: pointer; }
.card.picked { outline: 3px solid var(--tomato); outline-offset: 2px; }
tbody tr.picked { background: color-mix(in srgb, var(--tomato) 14%, transparent); }
th.sel-col, td.sel-col { width: 34px; padding-right: 0; }
th.sel-col input { width: 16px; height: 16px; accent-color: var(--tomato); }
.card .clip { margin-left: auto; font-weight: 600; white-space: nowrap; }

#selbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--card); border: var(--bw) solid var(--line); border-radius: 12px; box-shadow: 6px 6px 0 var(--shadow);
  padding: 10px 12px; max-width: calc(100vw - 24px);
}
#selbar .sel-n { font: 22px/1 var(--pixel); padding: 0 6px; }
#selbar .sel-n b { color: var(--tomato); font-weight: normal; }
body:has(#selbar:not([hidden])) main { padding-bottom: 110px; }

/* ---------- cancelled list ---------- */
.cancelled-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card.cancelled { cursor: pointer; opacity: .92; }
.card.cancelled .title { text-decoration: line-through; color: var(--muted); }
.card .actions-row { display: flex; gap: 6px; margin-top: 10px; }
.seg button b { font-weight: 600; }

/* ---------- thumbnails ---------- */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 92px; height: 92px; object-fit: cover; border: var(--bw) solid var(--line); border-radius: 7px; box-shadow: var(--sh-sm); background: var(--paper-2); }
.thumbs a:hover img { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }

/* ---------- prompt dialog ---------- */
dialog.wide { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog.wide .window-body { max-height: calc(100vh - 120px); overflow: auto; }
.prompt-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.prompt-toolbar #copy-all { margin-left: auto; }
.prompt-card { border: var(--bw) solid var(--line); border-radius: 9px; box-shadow: var(--sh-sm); background: var(--card); padding: 12px; margin-bottom: 14px; }
.prompt-head { display: flex; gap: 10px; align-items: center; }
.prompt-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-card pre {
  margin: 10px 0 0; padding: 10px 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.5 ui-monospace, Menlo, monospace; background: var(--paper-2); border: 1.5px dashed var(--line); border-radius: 7px;
}

/* ---------- review column & Claude runs ---------- */
.kanban { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-head.review { background: var(--violet); color: #fff; }
.tag.review { background: var(--violet); }
.bot-badge { display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--font); padding: 4px 7px; border-radius: 5px; border: 1.5px solid var(--line); background: var(--violet); color: #fff; }
.bot-badge.queued { background: var(--paper-2); color: var(--ink); }
.bot-badge .led { width: 8px; height: 8px; border-color: #fff; }

.run-box { border: var(--bw) solid var(--line); border-radius: 9px; background: var(--paper-2); padding: 12px; margin-top: 4px; }
.run-box h4 { margin: 0 0 8px; font: 22px/1 var(--pixel); display: flex; gap: 8px; align-items: center; }
.run-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.run-box select { flex: 1; min-width: 240px; }
.run-box textarea { min-height: 54px; }
.run-log { margin: 8px 0 0; max-height: 220px; overflow: auto; font: 12px/1.55 ui-monospace, Menlo, monospace; background: var(--card); border: 1.5px dashed var(--line); border-radius: 7px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; }
.run-result { background: var(--card); border: 1.5px solid var(--line); border-radius: 7px; padding: 10px 12px; margin-top: 8px; font-size: 13.5px; color: var(--ink); }
.run-result ul { margin: 4px 0 0; padding-left: 18px; }
.run-result .q { color: var(--tomato); font-weight: 600; white-space: pre-line; }
.run-result pre { white-space: pre-wrap; margin: 4px 0 0; font: 12.5px/1.5 ui-monospace, Menlo, monospace; }
.run-hist { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr; } }

/* Task dialog: keep title + footer visible, scroll the body. */
#dlg { max-height: calc(100vh - 32px); }
#dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 36px); }
#dlg .window-body { overflow: auto; min-height: 0; flex: 1; }

dialog.login { width: min(380px, calc(100vw - 32px)); }
dialog.login input { width: 100%; }
