/* Hệ thiết kế: lưới 4px, bề mặt sáng và điểm nhấn indigo. */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-900: #0f172a;
  --background: #fafafa;
  --surface: #fff;
  --border: var(--slate-200);
  --radius: 16px;
  --shadow: 0 4px 20px #0f172a06;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--slate-900);
  font: 400 14px/1.6 Inter,system-ui,sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,input,select {
  font: inherit;
}

button,a,input,select,summary {
  -webkit-tap-highlight-color: transparent;
}

a,button,summary {
  touch-action: manipulation;
}

a,button,input,select,summary {
  transition: background .18s,color .18s,border-color .18s,box-shadow .18s,transform .18s;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
}

h1,h2,h3,p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -.8px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: -.4px;
}

h3 {
  font-size: 16px;
  line-height: 1.5;
}

p {
  color: var(--slate-500);
}

small,.small {
  font-size: 12px;
}

.muted {
  color: var(--slate-500);
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--primary);
  text-transform: uppercase;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 100;
  background: white;
  padding: 12px;
}

.skip-link:focus {
  top: 12px;
}

.top-bar {
  height: 72px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: #ffffffed;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--slate-900);
  font-size: 16px;
  font-weight: 700;
  min-height: 48px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
}

.brand small {
  display: block;
  font-weight: 400;
  color: var(--slate-500);
  line-height: 1.3;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px;
  border-radius: 12px;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
}

.user-name {
  display: none;
}

.user-popover {
  position: absolute;
  right: 0;
  top: 56px;
  width: 260px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
  box-shadow: 0 16px 48px #0f172a1a;
}

.user-popover p {
  margin-bottom: 12px;
}

.user-popover a,.user-popover button {
  display: flex;
  width: 100%;
  align-items: center;
  min-height: 48px;
  padding: 12px;
  background: none;
  border: 0;
  color: var(--slate-900);
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}

.user-popover a:hover,.user-popover button:hover {
  background: var(--slate-100);
}

.main {
  max-width: 1200px;
  padding: 24px 16px calc(104px + env(safe-area-inset-bottom));
  margin: auto;
  min-width: 0;
}

.page-header {
  margin-bottom: 24px;
}

.page-header p {
  margin-top: 8px;
}

.page-header .eyebrow {
  margin-bottom: 8px;
}

.header-row,.section-header,.card-top,.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-row {
  align-items: flex-start;
}

.section {
  margin-top: 24px;
}

.section-header {
  margin-bottom: 16px;
}

.section-header a {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  font-weight: 500;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: #fffffffa;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.nav-item {
  min-height: 56px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 500;
  border-radius: 12px;
}

.nav-icon {
  font-size: 20px;
  line-height: 24px;
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-item:hover {
  background: var(--slate-100);
}

.nav-caption,.nav-footer {
  display: none;
}

.stat-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(148px,1fr);
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 0 0 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius);
  scroll-snap-align: start;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 500;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.4;
  margin: 8px 0;
}

.stat-card .hint {
  font-size: 12px;
  color: var(--slate-500);
}

.stat-card.accent {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stat-card.accent .label,.stat-card.accent .hint {
  color: #e0e7ff;
}

.card-grid,.stack {
  display: grid;
  gap: 16px;
}

.card,.schedule-card {
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-link {
  display: block;
  color: inherit;
}

.card-link:hover {
  border-color: #a5b4fc;
  box-shadow: 0 8px 24px #4f46e50a;
  transform: translateY(-2px);
}

.card-link:active,.btn:active {
  transform: translateY(1px);
}

.card-top {
  align-items: flex-start;
  flex-wrap: nowrap;
  margin-bottom: 16px;
}

.card-top>div {
  min-width: 0;
}

.card h3,.schedule-card h3 {
  overflow-wrap: anywhere;
}

.meta {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-100);
  font-size: 12px;
  color: var(--slate-500);
}

.card-footer strong {
  color: var(--primary);
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--slate-100);
  color: var(--slate-600);
}

.badge.da_chot,.badge.success {
  background: #ecfdf5;
  color: #047857;
}

.badge.cho_dang_ky,.badge.warning {
  background: #fffbeb;
  color: #92400e;
}

.badge.nhap {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.huy,.badge.danger {
  background: #fef2f2;
  color: #b91c1c;
}

.officers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.officer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 12px;
}

.officer-chip.lanh_dao {
  background: var(--primary-soft);
  color: var(--primary);
}

.officer-chip.chi_huy {
  background: #ecfdf5;
  color: #047857;
}

.shift-preview,.shift-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.shift-preview {
  padding: 12px 0;
  border-top: 1px solid var(--slate-100);
}

.shift-time {
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  min-width: 52px;
  font-weight: 600;
}

.shift-time small {
  display: block;
  color: var(--slate-500);
  font-weight: 400;
}

.shift-info {
  flex: 1;
  min-width: 0;
}

.shift-info .officers {
  margin-top: 12px;
}

.day-group {
  margin-top: 24px;
}

.day-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.day-header:after {
  content: '';
  height: 1px;
  background: var(--border);
  flex: 1;
}

.btn {
  min-height: 48px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--slate-600);
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}

.btn:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.field {
  display: grid;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

label {
  font-size: 14px;
  font-weight: 500;
}

input:not([type=hidden]),select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  color: var(--slate-900);
  font-size: 16px;
}

input:hover,select:hover {
  border-color: var(--slate-400);
}

.filter-form {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filter-form .field {
  flex-basis: 200px;
}

.filter-form select {
  max-width: 100%;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.empty-icon {
  height: 56px;
  width: 56px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 16px;
  font-size: 24px;
}

.empty-state p {
  max-width: 360px;
  margin: 8px auto 16px;
}

.list-group {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 16px;
  min-height: 88px;
  color: inherit;
}

.list-item+.list-item {
  border-top: 1px solid var(--slate-100);
}

.list-item:hover {
  background: var(--slate-50);
}

.list-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--primary-soft);
  border-radius: 12px;
  font-size: 20px;
  flex-shrink: 0;
}

.list-item .content {
  flex: 1;
  min-width: 0;
}

.list-item .title {
  font-size: 16px;
  font-weight: 600;
}

.list-item .subtitle {
  color: var(--slate-500);
  font-size: 12px;
  margin-top: 4px;
}

.chevron {
  color: var(--slate-400);
  font-size: 24px;
}

.alert {
  padding: 16px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 16px;
}

.alert-error,.alert-danger {
  background: #fef2f2;
  color: #b91c1c;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
}

.alert-success {
  background: #ecfdf5;
  color: #047857;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.metric-list {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.metric-list strong {
  display: block;
  font-size: 20px;
}

.metric-list span {
  font-size: 12px;
  color: var(--slate-500);
}

.progress {
  width: 100%;
  height: 8px;
  accent-color: var(--primary);
  margin-top: 16px;
}

.login-page {
  min-height: 100svh;
  background: radial-gradient(ellipse at 15% 15%,#e0e7ff 0,transparent 55%),radial-gradient(ellipse at 90% 90%,#ede9fe 0,transparent 55%),var(--slate-50);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: 0 24px 80px #312e8110;
}

.login-card .brand-mark {
  margin-bottom: 24px;
  width: 48px;
  height: 48px;
}

.login-card h1 {
  margin: 8px 0;
}

.login-card form {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.login-card .help {
  font-size: 12px;
  text-align: center;
  margin-top: 24px;
}

.login-card .alert {
  margin-top: 16px;
}

.login-card .errorlist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.htmx-request {
  opacity: .65;
}

.htmx-request button {
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media(min-width:640px) {
  .main {
    padding: 32px 24px 112px;
  }
  .card-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .user-name {
    display: block;
    font-size: 12px;
  }
  .stat-scroll {
    gap: 16px;
  }
  .login-card {
    padding: 40px 32px;
  }
}

@media(min-width:1024px) {
  .top-bar {
    padding: 0 32px;
  }
  .main {
    margin-left: 240px;
    max-width: 1360px;
    padding: 40px 40px 64px;
  }
  .bottom-nav {
    top: 72px;
    bottom: 0;
    right: auto;
    width: 240px;
    border-top: 0;
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
  }
  .nav-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
    gap: 12px;
    font-size: 14px;
    min-height: 48px;
  }
  .nav-caption {
    display: block;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--slate-400);
    padding: 0 16px 12px;
  }
  .nav-footer {
    display: block;
    margin-top: auto;
    padding: 16px;
    color: var(--slate-400);
    font-size: 12px;
  }
  h1 {
    font-size: 32px;
  }
  .page-header {
    margin-bottom: 32px;
  }
  .stat-card {
    padding: 20px;
  }
  .section {
    margin-top: 32px;
  }
  .management-menu {
    max-width: 800px;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after {
    transition: none!important;
    scroll-behavior: auto!important;
  }
}
