* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: #f4f6f9;
  color: #263445;
  font-family: Arial, Helvetica, sans-serif;
}

.brand { padding: 30px 16px 16px; text-align: center; }
.brand-symbol { color: #c79a36; font-size: 42px; }
.agency-name { color: #a4242b; font-size: 14px; font-weight: bold; letter-spacing: 1px; }
h1 { color: #a4242b; font-size: 24px; line-height: 1.4; margin: 12px auto; }
.subtitle, .hint { color: #66758a; font-size: 13px; line-height: 1.6; }

.main-layout { min-height: calc(100vh - 250px); padding: 14px 16px 40px; }
.login-card {
  width: 100%; max-width: 420px; margin: 30px auto;
  background: white; padding: 32px; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .07);
}
.login-card h2 { font-size: 22px; margin-top: 0; }
.login-card label { display: block; margin: 18px 0 8px; font-size: 14px; font-weight: bold; }
.login-card input {
  width: 100%; padding: 13px; border: 1px solid #ccd2db;
  border-radius: 7px; font: inherit;
}
.login-card input:focus, select:focus { outline: 2px solid #a4242b; outline-offset: 1px; }
button {
  padding: 12px 20px; background: #a4242b; color: white; border: 0;
  border-radius: 8px; font-size: 14px; font-weight: bold; cursor: pointer;
}
button:hover { background: #851b21; }
button:disabled { opacity: .6; cursor: wait; }
.login-card button { width: 100%; }
.message { color: #b91c1c; font-size: 13px; line-height: 1.5; }

.workspace { width: 100%; max-width: 1200px; margin: 0 auto; }
.workspace-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; padding: 20px 24px;
  border-radius: 14px; background: #fff;
  border-top: 4px solid #a4242b;
  box-shadow: 0 5px 20px rgba(0,0,0,.05);
}
.workspace-top h2 { margin: 0 0 6px; font-size: 22px; }
.workspace-top .hint { margin: 0; }
.account-area { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 14px; }
.account-email { font-size: 12px; color: #66758a; overflow-wrap: anywhere; }
.logout-button { margin-top: 5px; padding: 9px 16px; }
.notice { margin: 14px 0 5px; font-size: 14px; color: #15703b; }
.notice.error { color: #b91c1c; }
.role-line { margin: 4px 0 18px; color: #566477; font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  min-height: 110px; padding: 17px 14px; background: #fff;
  border: 1px solid #e5e8ed; border-radius: 12px;
  box-shadow: 0 3px 12px rgba(0,0,0,.035);
}
.stat-card span { display: block; color: #5d6a7a; font-size: 13px; line-height: 1.4; }
.stat-card strong { display: block; margin-top: 13px; font-size: 29px; color: #263445; }
.stat-warning { border-top: 3px solid #c62828; }
.stat-danger { border-top: 3px solid #a4242b; }
.stat-warning strong, .stat-danger strong { color: #b91c1c; }

.tasks-panel { background: #fff; border: 1px solid #e4e8ee; border-radius: 14px; overflow: hidden; }
.panel-head {
  padding: 20px; display: flex; justify-content: space-between;
  align-items: flex-end; gap: 18px; flex-wrap: wrap;
}
.panel-head h3 { margin: 0 0 5px; font-size: 19px; }
.panel-head .hint { margin: 0; }
.filter-group { display: flex; flex-direction: column; gap: 7px; }
.filter-group label { font-size: 12px; font-weight: bold; }
.filter-group select { background: #fff; border: 1px solid #cdd4dd; border-radius: 7px; padding: 10px; font-size: 14px; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; font-size: 13px; }
thead { background: #f5f6f8; }
th { text-align: left; color: #405069; font-weight: bold; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
tbody tr:hover { background: #fafbfc; }
.task-title { min-width: 240px; font-weight: bold; line-height: 1.5; }
.task-details { margin-top: 7px; color: #4e5e73; font-weight: normal; }
.task-details summary { font-size: 12px; cursor: pointer; color: #a4242b; }
.task-details p { margin: 6px 0; font-size: 12px; }
.flag { display: inline-block; padding: 5px 9px; border-radius: 20px; white-space: nowrap; font-size: 12px; font-weight: bold; }
.flag-neutral { color: #465569; background: #e8edf2; }
.flag-doing { color: #1c5c91; background: #e7f2fc; }
.flag-done { color: #18713d; background: #e6f5eb; }
.flag-alert { color: #b91c1c; background: #fee8e8; }
.empty-cell { text-align: center; padding: 25px; color: #657388; }
#taskStatus { margin: 12px 20px 20px; }

footer { padding: 18px; color: #697586; text-align: center; font-size: 12px; }
@media (max-width: 950px) { .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 600px) {
  .brand { padding-top: 20px; }
  h1 { font-size: 19px; }
  .login-card { padding: 24px; }
  .workspace-top { padding: 16px; }
  .workspace-top h2 { font-size: 19px; }
  .account-area { align-items: flex-start; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-card { min-height: 95px; }
  .stat-card strong { font-size: 25px; }
  .panel-head { padding: 16px; }
}

/* Bước 21: biểu mẫu tạo công việc - kế thừa Dashboard bước 20 */
.create-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin: 0 0 15px;
}
.create-toolbar h3 { margin: 0 0 4px; font-size: 18px; }
.create-toolbar .hint { margin: 0; }
.task-form-panel {
  background: #fff; border: 1px solid #e2e6ed; border-top: 3px solid #a4242b;
  border-radius: 12px; padding: 22px; margin-bottom: 18px;
  box-shadow: 0 3px 12px rgba(0,0,0,.035);
}
.task-form-heading h3 { margin: 0 0 5px; font-size: 19px; }
.task-form-heading .hint { margin: 0 0 14px; }
.task-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full-width { grid-column: 1 / -1; }
.form-field label { font-weight: bold; font-size: 13px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; min-width: 0; padding: 11px 12px;
  border: 1px solid #cbd3de; border-radius: 7px; font: inherit;
  font-size: 14px; background: #fff; color: #263445;
}
.form-field textarea { resize: vertical; line-height: 1.5; }
.form-field input[readonly] { background: #f2f4f7; color: #526175; }
.form-field :is(input, select, textarea):focus { outline: 2px solid #a4242b; outline-offset: 1px; }
.form-field small { font-size: 12px; color: #66758a; line-height: 1.5; }
.required { color: #b91c1c; }
.task-form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button-secondary { background: #e9edf2; color: #304158; }
.button-secondary:hover { background: #dce2e9; }
.save-feedback {
  margin: 0 0 15px; padding: 11px 14px; border-radius: 8px;
  color: #126333; background: #e7f6ec; font-size: 14px;
}
.save-feedback.error { color: #a4242b; background: #fff0f0; }
@media (max-width: 600px) {
  .task-form-grid { grid-template-columns: 1fr; }
  .task-form-panel { padding: 16px; }
  .create-toolbar button { width: 100%; }
  .task-form-actions button { flex: 1; }
}

/* Bước 22: nút chỉnh sửa công việc; giữ nguyên bố cục Bước 21 */
.task-action-cell { min-width: 105px; }
.edit-task-button {
  padding: 8px 12px;
  border: 1px solid #a4242b;
  background: #fff;
  color: #a4242b;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.edit-task-button:hover { background: #fff0f1; }
.edit-task-button:focus-visible { outline: 2px solid #a4242b; outline-offset: 2px; }
.task-update-time { color: #68778c; font-size: 12px; }
#editTaskPanel { scroll-margin-top: 24px; }


/* Bước 25: xem công việc theo phòng và toàn cơ quan; giữ nguyên mẫu Bước 22 */
.scope-note {
  margin: 10px 0 12px; color: #566477; font-size: 13px;
}
.filters-bar {
  padding: 0 20px 18px; display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.filters-bar .filter-group { min-width: 0; }
.filters-bar select {
  width: 100%; background: #fff; color: #263445;
  border: 1px solid #cdd4dd; border-radius: 7px;
  padding: 10px; font-size: 14px;
}
.filters-bar select:disabled { background: #f0f3f6; color: #526175; }
.owner-info { line-height: 1.5; min-width: 170px; }
.owner-info strong { display: block; }
.owner-info small { display: block; color: #677487; font-size: 12px; }
#refreshTasksBtn { white-space: nowrap; padding: 9px 15px; }
@media (max-width: 750px) {
  .filters-bar { grid-template-columns: 1fr; padding: 0 16px 16px; }
}


/* BƯỚC 29: Dashboard tổng hợp dành riêng cho Lãnh đạo Văn phòng.
   Chỉ bổ sung kiểu dáng, giữ nguyên toàn bộ CSS của các bước trước. */
.leader-dashboard {
  margin: 0 0 22px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid #e3e8ef;
  border-top: 4px solid #a4242b;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .04);
}
.leader-dashboard-heading h3 {
  margin: 0 0 7px;
  color: #8a2027;
  font-size: 21px;
}
.leader-dashboard-heading .hint { margin: 0 0 18px; }
.leader-section + .leader-section { margin-top: 22px; }
.leader-section-heading { margin: 0 0 12px; }
.leader-section-heading h4 { margin: 0 0 5px; font-size: 16px; }
.leader-section-heading .hint { margin: 0; }
.leader-department-table { min-width: 1080px; }
.leader-department-table th { white-space: nowrap; }
.leader-department-table td { vertical-align: middle; }
.leader-department-table td:first-child { min-width: 225px; }
.leader-department-table td:not(:first-child):not(:last-child) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.leader-department-table th:not(:first-child):not(:last-child) { text-align: center; }
.leader-department-table .leader-total-row { background: #f9f2f3; font-weight: bold; }
.leader-department-table .leader-alert-number { color: #b91c1c; font-weight: bold; }
.leader-progress { min-width: 96px; }
.leader-progress-label { display: block; margin-bottom: 5px; font-size: 12px; white-space: nowrap; }
.leader-progress-track { height: 7px; border-radius: 5px; background: #e9edf2; overflow: hidden; }
.leader-progress-fill { height: 100%; background: #287a50; border-radius: 5px; }
.leader-filter-button {
  padding: 7px 10px;
  border: 1px solid #a4242b;
  border-radius: 7px;
  background: #fff;
  color: #a4242b;
  font-size: 12px;
  white-space: nowrap;
}
.leader-filter-button:hover { background: #fff0f1; }
.leader-priority-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.leader-priority-item {
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid #e5e9ef;
  border-left: 3px solid #c43239;
  border-radius: 8px;
  background: #fcfcfd;
}
.leader-priority-item h5 {
  margin: 9px 0 6px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: bold;
  overflow-wrap: anywhere;
}
.leader-priority-meta { margin: 0 0 9px; font-size: 12px; line-height: 1.6; color: #586779; }
.leader-priority-item .leader-filter-button { margin-top: 2px; }
.leader-priority-note { margin: 12px 0 0; }
.leader-priority-empty {
  grid-column: 1 / -1;
  padding: 16px;
  background: #edf7f0;
  color: #17613a;
  border-radius: 8px;
  font-size: 14px;
}
.leader-focused-task { outline: 2px solid #a4242b; outline-offset: -2px; background: #fff4f4 !important; }
@media (max-width: 750px) {
  .leader-dashboard { padding: 15px; }
  .leader-priority-list { grid-template-columns: 1fr; }
  .leader-dashboard-heading h3 { font-size: 19px; }
}
