/* Mau theo bo nhan dien AIURIS Law Firm (giong cong cu So thue tren hiepls.vn):
   den than #231F20, vang dong #B8A574, tieu de Times New Roman. */
:root {
  --logo-black: #231f20;
  --logo-gold: #b8a574;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f3eee2;
  --ink: #231f20;
  --muted: #6b6460;
  --line: #e6e0d3;
  --accent: #231f20;        /* nut chinh: den than */
  --accent-ink: #ffffff;
  --accent-text: #7a6a3e;   /* vang dam cho chu, lien ket (du tuong phan tren nen trang) */
  --accent-soft: #f3eee2;
  --gold: #b8a574;
  --red: #b3261e;
  --red-soft: #fdecea;
  --amber: #7a5a00;
  --amber-soft: #fbf3dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 31, 32, 0.06), 0 2px 8px rgba(35, 31, 32, 0.05);
  --serif: "Times New Roman", Times, "Liberation Serif", "Noto Serif", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141213;
    --surface: #1f1c1d;
    --surface-2: #2c2720;
    --ink: #efe9dd;
    --muted: #a89f95;
    --line: #3a3433;
    --accent: #c9b688;
    --accent-ink: #1a1718;
    --accent-text: #d4c294;
    --accent-soft: #2c2720;
    --gold: #c9b688;
    --red: #ff8a80;
    --red-soft: #3a1c1a;
    --amber: #e8cf8a;
    --amber-soft: #352d1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 0; }

/* Thanh dau giu nen trang ca o che do toi de logo dung mau (giong So thue) */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: #fff;
  color: var(--logo-black);
  border-bottom: 3px solid var(--logo-gold);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; color: inherit; }
.logo { height: 40px; width: auto; flex: none; }
.app-name { border-left: 1px solid var(--logo-gold); padding-left: 12px; min-width: 0; }
.app-name b { display: block; font-family: var(--serif); font-size: 19px; line-height: 1.15; }
.app-name span { display: block; font-size: 12px; color: #6b6460; white-space: nowrap; }
h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 10px; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 14px; }

.icon-btn {
  border: 1px solid var(--logo-gold);
  background: #fff;
  color: var(--logo-black);
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin: 10px 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.card.add .label { margin-top: 0; }

textarea, input[type="text"], input[type="date"], input[type="time"], input[type="number"] {
  width: 100%;
  font: inherit;
  font-size: 17px; /* >=16px de iPhone khong tu phong to khi go */
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; min-height: 84px; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.hint { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin: 6px 0 10px; }

.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.stack { display: grid; gap: 8px; margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  flex: 1;
  text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: var(--surface-2); border-color: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red-soft); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 14px; flex: 0 0 auto; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }

.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 16px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.actions { display: grid; gap: 8px; margin-top: 14px; }

.ocr-status { margin-top: 10px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

.cand-title { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.cand {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px; border-radius: 10px; background: var(--surface-2); margin-bottom: 6px;
}
.cand .txt { font-size: 14px; min-width: 0; }
.cand .txt b { display: block; font-size: 15px; }

.note, .issue {
  font-size: 14px; border-radius: 10px; padding: 8px 10px; margin: 8px 0 0; display: flex; gap: 8px;
}
.note { background: var(--surface-2); color: var(--ink); }
.issue.trung { background: var(--red-soft); color: var(--red); }
.issue.sat { background: var(--amber-soft); color: var(--amber); }
.issue.ok { background: var(--accent-soft); color: var(--accent-text); }

.banner { border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; font-size: 15px; }
.banner.info { background: var(--accent-soft); color: var(--ink); border-left: 3px solid var(--gold); }
.banner.warn { background: var(--amber-soft); color: var(--ink); }
.banner b { display: block; margin-bottom: 2px; }
.banner .row { margin-top: 8px; }

.tabs {
  display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin: 18px 0 8px;
  position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 2;
}
.tab {
  flex: 1; border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 15px;
  color: var(--muted); padding: 8px; border-radius: 9px; min-height: 38px;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); border-bottom: 2px solid var(--gold); }

.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 2px 6px; }
.day-head b { font-family: var(--serif); font-size: 17px; }
.day-head span { font-size: 13px; color: var(--muted); }
.day-head .rel { color: var(--accent-text); font-weight: 700; margin-right: 6px; }

.ev {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 6px; cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
}
.ev.trung { border-left: 4px solid var(--red); }
.ev.sat { border-left: 4px solid var(--amber); }
.ev.past { opacity: 0.55; }
.ev .time { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.ev .time small { display: block; color: var(--muted); font-weight: 500; }
.ev .title { font-weight: 600; overflow-wrap: anywhere; }
.ev .meta { font-size: 13px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 99px; }
.badge.trung { background: var(--red-soft); color: var(--red); }
.badge.sat { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--accent-soft); color: var(--accent-text); }
.badge.todo { background: var(--surface-2); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 15px; }
.empty-day { font-size: 13px; color: var(--muted); padding: 2px 2px 6px; }

.nav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px; }
.nav b { font-family: var(--serif); font-size: 18px; }
.nav .btn { flex: 0 0 auto; min-width: 44px; }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.month .dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cell {
  aspect-ratio: 1 / 1.05; border: 0; border-radius: 10px; background: var(--surface); font: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 0 0; gap: 4px;
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.cell.other { opacity: 0.35; }
.cell.today { outline: 2px solid var(--gold); }
.cell.sel { background: var(--accent); color: var(--accent-ink); }
.dots { display: flex; gap: 3px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.cell.sel .dot { background: var(--accent-ink); }
.dot.trung { background: var(--red); }
.dot.sat { background: var(--amber); }

.show-past { margin: 10px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 32px); z-index: 10;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100% - 24px));
  background: var(--surface); color: var(--ink); max-height: calc(100% - 40px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.settings { padding: 18px; }
.settings fieldset { border: 0; padding: 0; margin: 10px 0 0; }
.settings details { margin-top: 14px; font-size: 15px; }
.settings summary { font-weight: 600; min-height: 32px; }
.settings ol { padding-left: 20px; margin: 6px 0; }

@media (max-width: 360px) {
  .grid2 { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 56px 1fr; }
}

.credit { text-align: center; font-size: 12.5px; color: var(--muted); margin: 22px 16px 8px; letter-spacing: 0.01em; }
.credit::before { content: "✦ "; color: var(--logo-gold); }
.credit a { color: inherit; }

@media (max-width: 380px) {
  .logo { height: 32px; }
  .app-name b { font-size: 17px; }
  .app-name span { display: none; }
}
