:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
}
.hidden { display: none !important; }

header {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
header .title { font-size: 18px; font-weight: 600; }
header .user-box { display: flex; align-items: center; gap: 10px; font-size: 14px; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 10px;
  padding: 12px 16px; font-weight: 600; min-height: 44px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: rgba(255,255,255,.2); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); padding: 8px 12px; }
.btn-block { width: 100%; }
button:disabled { opacity: .55; cursor: not-allowed; }

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

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 28px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.msg { margin-top: 12px; font-size: 14px; min-height: 20px; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--success); }
.switch-line { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.switch-line a { color: var(--primary); font-weight: 600; text-decoration: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { flex: 1 1 160px; }
.toolbar .field label { margin-top: 0; }
.toolbar .actions { flex: 0 0 auto; }

.task-count { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
thead th {
  text-align: left; padding: 12px 14px; font-size: 13px; color: var(--muted);
  background: #f8fafc; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-chualam { background: #f1f5f9; color: #475569; }
.st-danglam { background: #fef3c7; color: #92400e; }
.st-xong    { background: #dcfce7; color: #166534; }
.pr-thap    { background: #e0f2fe; color: #075985; }
.pr-trungbinh { background: #ede9fe; color: #5b21b6; }
.pr-cao     { background: #fee2e2; color: #991b1b; }
.overdue { color: var(--danger); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; background: var(--card); border-radius: var(--radius); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 40;
}
.modal {
  background: var(--card); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0;
  padding: 20px; max-height: 92vh; overflow-y: auto; box-shadow: 0 -4px 30px rgba(0,0,0,.2);
}
.modal h2 { margin: 0 0 16px; font-size: 19px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal .modal-actions button { flex: 1; }

.chk-group {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
  max-height: 180px; overflow-y: auto;
}
.chk { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; cursor: pointer; }
.chk input { width: auto; min-height: 0; margin: 0; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.loading-overlay .spinner { border-color: rgba(37,99,235,.3); border-top-color: var(--primary); width: 36px; height: 36px; }

.detail-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.detail-title { margin: 0 0 12px; font-size: 15px; }
.att-upload { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.att-pick { display: inline-block; background: #eef2ff; color: var(--primary); border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.att-status { font-size: 13px; color: var(--muted); }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.att-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.att-thumb { width: 100%; height: 100px; object-fit: cover; display: block; background: #f1f5f9; }
.att-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; font-size: 11px; color: var(--muted); }
.att-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cmt-form { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 14px; }
.cmt-form textarea { flex: 1; min-height: 44px; }
.cmt-form button { flex: 0 0 auto; align-self: stretch; }
.cmt-list { display: flex; flex-direction: column; gap: 12px; }
.cmt-item { background: #f8fafc; border-radius: 10px; padding: 10px 12px; }
.cmt-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.cmt-head b { color: var(--text); }
.cmt-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 640px) {
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  table { background: transparent; box-shadow: none; }
  tbody tr { background: var(--card); border-radius: var(--radius); margin-bottom: 12px; padding: 6px 4px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
  tbody td { border: none; padding: 8px 14px; display: flex; justify-content: space-between; gap: 12px; }
  tbody td.td-title { display: block; }
  .cell-label { display: inline-block; font-size: 12px; color: var(--muted); font-weight: 600; flex: 0 0 auto; }
  .cell-value { text-align: right; flex: 1 1 auto; }
  td.td-title .cell-value { text-align: left; font-size: 16px; font-weight: 600; }
  .row-actions { justify-content: flex-start; }
  .modal-overlay { align-items: center; padding: 16px; }
  .modal { border-radius: 16px; }
  header .title { font-size: 16px; }
  header .user-box .hoten { display: none; }
}

/* Desktop: ẩn nhãn card */
@media (min-width: 641px) { .cell-label { display: none; } }
