:root {
  --bg: #0f1412;
  --panel: #1a211e;
  --ink: #e8efe9;
  --muted: #8a9a90;
  --line: #2c3832;
  --accent: #3dba7a;
  --danger: #e24b4b;
  --warn: #e2a23a;
  --btn: #24302b;
  --max: 1100px;
  font-family: "Segoe UI", "Sarabun", system-ui, -apple-system, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #14201a;
  --muted: #5b6b62;
  --line: #d5ddd8;
  --btn: #e7eee9;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
body { display: flex; flex-direction: column; min-height: 100vh; padding-bottom: 2.4rem; }
body, button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
header {
  position: sticky; top: 0; z-index: 20; background: var(--panel);
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  justify-content: space-between; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.brand a, .pm-home {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: inherit; text-decoration: none; font-weight: 700; letter-spacing: 0.02em;
}
.pm-lockup { height: 36px; width: auto; display: none; }
:root[data-theme="dark"] .pm-lockup-dark, :root:not([data-theme]) .pm-lockup-dark { display: block; }
:root[data-theme="light"] .pm-lockup-light { display: block; }
:root[data-theme="light"] .pm-lockup-dark { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
nav { display: flex; flex-wrap: wrap; gap: 0.35rem; flex: 1; }
.tab, .btn {
  appearance: none; min-height: 44px; border: 1px solid var(--line); background: var(--btn);
  color: var(--ink); border-radius: 10px; padding: 0.55rem 0.8rem; font-size: 0.95rem; cursor: pointer;
}
header button.active, .tab.active { outline: 2px solid var(--accent); }
button.primary, .btn.primary {
  background: var(--accent); color: #062214; border-color: transparent; font-weight: 700;
}
button.danger, .btn.danger { background: var(--danger); color: #fff; border-color: transparent; font-weight: 700; }
main { max-width: var(--max); margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; width: 100%; flex: 1; }
.status-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between;
  padding: 0.35rem 0.9rem; font-size: 0.78rem; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.work-jobs { display: grid; gap: 1rem; }
@media (min-width: 960px) {
  .work-jobs { grid-template-columns: 1.4fr 0.9fr; align-items: start; }
}
.ticket { cursor: pointer; }
.ticket.active { outline: 2px solid var(--accent); }
#tix-edit textarea { width: 100%; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
}
h1 { margin: 0 0 0.4rem; font-size: 1.6rem; }
h2 { margin: 0 0 0.75rem; font-size: 1rem; color: var(--muted); font-weight: 600; }
.muted, .note { color: var(--muted); }
.grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.1rem;
}
.card strong { display: block; font-size: 1.15rem; margin-bottom: 0.35rem; }
.low { color: var(--warn); }
label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  appearance: none; min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); padding: 0.7rem 0.9rem; font: inherit;
}
textarea { min-height: 5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45rem 0.3rem; border-bottom: 1px solid var(--line); }
.kanban { display: grid; gap: 0.7rem; grid-template-columns: repeat(4, minmax(160px, 1fr)); }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr 1fr; } }
.col { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; min-height: 12rem; }
.col h3 { margin: 0 0 0.5rem; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ticket {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.55rem; margin-bottom: 0.45rem;
}
.ticket small { display: block; color: var(--muted); margin-top: 0.25rem; }
[hidden] { display: none !important; }
.err { color: var(--danger); margin: 0; }
.tiles { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.tile { background: var(--bg); border-radius: 10px; padding: 0.8rem; }
.tile span { display: block; color: var(--muted); font-size: 0.8rem; }
.tile strong { display: block; font-size: clamp(1.4rem, 4vw, 2.2rem); }
.tile.hero strong { color: var(--accent); }
.lock { max-width: 36rem; }
.dm-profile { position: relative; }
.dm-profile-trigger {
  appearance: none;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0 0.35rem 0 0.65rem; border: 2px solid var(--line);
  border-radius: 999px; background: var(--panel); color: var(--ink);
  cursor: pointer; min-height: 40px;
}
.dm-profile-trigger-name {
  font-size: 0.85rem; font-weight: 600; max-width: 9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 560px) {
  .dm-profile-trigger-name { display: none; }
  .dm-profile-trigger { padding: 0; width: 40px; height: 40px; }
}
.dm-avatar { width: 36px; height: 36px; border-radius: 999px; object-fit: cover; background: var(--btn); }
.dm-avatar-lg { width: 48px; height: 48px; }
.dm-profile-menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 16rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.4rem; display: flex; flex-direction: column; gap: 0.1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 40;
}
.dm-profile-menu[hidden] { display: none !important; }
.dm-profile-menu-header { display: flex; gap: 0.75rem; align-items: center; padding: 0.65rem 0.55rem 0.75rem; }
.dm-profile-name { font-weight: 600; }
.dm-profile-meta { font-size: 0.75rem; color: var(--muted); }
.dm-profile-menu > a, .dm-profile-menu > button[role="menuitem"] {
  appearance: none;
  display: block; width: 100%; text-align: left; padding: 0.55rem 0.65rem;
  border: none; border-radius: 6px; background: transparent; color: var(--ink); font: inherit;
  cursor: pointer;
}
.dm-profile-sep { height: 1px; background: var(--line); margin: 0.35rem 0.25rem; }
.dm-profile-theme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; padding: 0.35rem 0.4rem; font-size: 0.8rem; }
.dm-profile-theme.dm-profile-lang { grid-template-columns: 1fr 1fr; }
.dm-profile-theme > span { grid-column: 1 / -1; color: var(--muted); }
.dm-profile-theme button {
  appearance: none;
  border: 1px solid var(--line); background: var(--btn); color: var(--ink);
  border-radius: 6px; padding: 0.5rem 0.2rem; min-height: 44px; font-size: 0.75rem; cursor: pointer;
}
.dm-profile-theme button[aria-pressed="true"] {
  border-color: var(--accent); color: var(--accent); font-weight: 600; outline: none;
}
.pm-err {
  position: fixed; left: 0; right: 0; bottom: 2.2rem; z-index: 40;
  display: flex; gap: 0.75rem; align-items: center; justify-content: space-between;
  padding: 0.65rem 1rem; background: #5c1a1a; color: #fff; font-size: 0.95rem;
}
.pm-err[hidden] { display: none; }
.pm-err-close {
  border: 0; background: transparent; color: inherit; font-size: 1.4rem;
  line-height: 1; min-height: 44px; min-width: 44px; cursor: pointer;
}
