:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar: #08152f;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #b4232f;
  --primary-soft: #fde8ea;
  --accent-soft: #f3f4f6;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #08152f 0%, #051126 100%);
  color: #fff; padding: 20px; height: 100vh; position: sticky; top: 0; overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
}
.brand {
  display: flex; align-items: center; gap: 14px; margin-bottom: 28px; padding: 18px 16px;
  background: rgba(255,255,255,0.95); border-radius: 22px; width: 100%; color: #000;
}
.brand-logo {
  width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center; padding: 8px; overflow: hidden; flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand h1 { font-size: 18px; margin: 0; line-height: 1.25; }
.brand small { color: rgba(0,0,0,0.7); }
.nav-section {
  margin: 24px 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.6); padding: 0 14px;
}
.nav a {
  display: block; text-decoration: none; color: #f3f4f6; padding: 16px 18px; border-radius: 18px;
  margin-bottom: 10px; background: transparent; font-size: 16px; width: 100%;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.main { padding: 24px; min-width: 0; }

/* Hamburger Toggle */
.sidebar-toggle {
  display: none; background: var(--primary); color: #fff; border: none; border-radius: 12px;
  width: 42px; height: 42px; font-size: 22px; cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 200; flex-shrink: 0;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
}

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 220px; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn {
  border: none; border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 600;
  font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #8f1c25); color: #fff; box-shadow: 0 10px 20px rgba(180,35,47,0.22); }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:hover { transform: translateY(-1px); transition: 0.2s ease; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.user-chip {
  background: white; border: 1px solid var(--border); border-radius: 999px; padding: 6px 16px 6px 6px;
  box-shadow: var(--shadow); font-size: 14px; cursor: pointer; transition: box-shadow 0.2s;
}
.user-chip:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); text-decoration: none !important; }

/* Page */
.page { margin-bottom: 30px; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 28px; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }

/* Grids */
.grid-4, .grid-3, .grid-2 { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.hero-card { background: linear-gradient(135deg, #ffffff, #fafafb); border-top: 4px solid var(--primary); }
.punch-card { background: linear-gradient(135deg, #ffffff, #fff7f8); border: 1px solid #f3d6da; }
.stat-label { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; margin-bottom: 8px; }
.punch-time { font-size: 34px; font-weight: 700; margin: 6px 0; color: #0f172a; }

/* Pills / Badges */
.pill { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--primary-soft); color: var(--primary); }
.pill-accent { background: var(--accent-soft); color: #374151; }

/* Section */
.section-title { margin: 0 0 14px; font-size: 18px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 700; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Progress */
.progress-wrap { background: #e8eefb; border-radius: 999px; height: 10px; overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #d14b56); border-radius: 999px; }

/* Lists */
.list { display: grid; gap: 12px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.muted { color: var(--muted); }
.mini-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: #fafafa; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { min-height: 100px; resize: vertical; }
.span-2 { grid-column: span 2; }

/* Punch */
.punch-meta { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 18px; }
.punch-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.punch-note { margin-top: 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Filter bar */
.filter-bar {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px; margin-bottom: 18px; align-items: end;
}
.filter-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Two-card row */
.two-card-row {
  display: grid; grid-template-columns: minmax(320px, 0.95fr) minmax(520px, 1.05fr);
  gap: 18px; align-items: stretch; margin-top: 18px;
}
.two-card-row > .card { min-width: 0; height: 100%; }

/* Summary card tables */
.summary-card { overflow: hidden; }
.summary-card .table-wrap { width: 100%; overflow-x: auto; }
.summary-card table { min-width: 640px; table-layout: fixed; width: 100%; }
.summary-card th, .summary-card td { white-space: normal; word-break: break-word; vertical-align: top; }
.summary-card th:nth-child(1), .summary-card td:nth-child(1) { width: 26%; }
.summary-card th:nth-child(2), .summary-card td:nth-child(2) { width: 12%; }
.summary-card th:nth-child(3), .summary-card td:nth-child(3) { width: 14%; }
.summary-card th:nth-child(4), .summary-card td:nth-child(4) { width: 12%; }
.summary-card th:nth-child(5), .summary-card td:nth-child(5) { width: 16%; }
.summary-card th:nth-child(6), .summary-card td:nth-child(6) { width: 20%; }

/* Day punch card */
.day-punch-card { overflow: hidden; }
.day-punch-card table { table-layout: fixed; width: 100%; }
.day-punch-card th { width: 42%; }
.day-punch-card td { width: 58%; }
.day-punch-card th, .day-punch-card td { white-space: normal; word-break: break-word; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  padding: 10px 22px; font-weight: 600; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; text-decoration: none;
  transition: all 0.2s; white-space: nowrap; flex-shrink: 0;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Announcements */
.announcement-strip {
  padding: 12px 18px; border-radius: 14px; margin-bottom: 10px; font-size: 14px; line-height: 1.5;
}
.announcement-important { background: var(--warning-soft); border-left: 4px solid var(--warning); }
.announcement-policy { background: var(--primary-soft); border-left: 4px solid var(--primary); }
.announcement-celebration { background: var(--success-soft); border-left: 4px solid var(--success); }
.announcement-urgent { background: var(--danger-soft); border-left: 4px solid var(--danger); }

/* Alerts & Messages */
.alert {
  padding: 14px 18px; border-radius: 14px; margin-bottom: 16px; font-size: 14px;
}
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--primary-soft); color: var(--primary); border: 1px solid #fbb6bc; }

/* Login page */
.login-container {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #08152f 0%, #0f2447 50%, #1a3a6e 100%);
  padding: 16px;
}
.login-card {
  background: var(--card); border-radius: 24px; padding: 48px 40px; width: 100%; max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.login-card .brand-logo { margin: 0 auto 20px; width: 72px; height: 72px; }
.login-card h1 { text-align: center; font-size: 24px; margin: 0 0 8px; }
.login-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.login-card .forgot-link { display: block; text-align: center; margin-top: 16px; color: var(--muted); font-size: 13px; }
.login-card .forgot-link a { color: var(--primary); }

/* Calendar view */
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-header { text-align: center; font-weight: 700; font-size: 12px; color: var(--muted); padding: 8px; }
.calendar-day {
  min-height: 80px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; background: #fff;
}
.calendar-day .day-num { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.calendar-day.today { border-color: var(--primary); background: var(--primary-soft); }
.calendar-day.weekend { background: #f9fafb; }
.calendar-day.holiday { background: var(--warning-soft); }
.calendar-leave-tag {
  display: block; padding: 2px 6px; border-radius: 4px; font-size: 11px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Footer */
.footer-note { text-align: center; color: var(--muted); padding: 20px 0 8px; font-size: 13px; }

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Large desktop down */
@media (max-width: 1280px) {
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-card-row { grid-template-columns: 1fr; }
  .summary-card { overflow-x: auto; }
  .summary-card table { min-width: 680px; }
}

/* Tablet landscape */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet */
@media (max-width: 1024px) {
  .app { grid-template-columns: 260px 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 24px; }
  .page-title { font-size: 24px; }
}

/* Tablet portrait / small tablet */
@media (max-width: 860px) {
  /* Sidebar becomes off-canvas drawer */
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: -300px; width: 280px; height: 100vh;
    transition: left 0.3s ease; z-index: 100;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; }
  .sidebar-toggle { display: flex; }

  .main { padding: 16px; }
  .page-title { font-size: 22px; }
  .stat-value { font-size: 22px; }
  .punch-time { font-size: 28px; }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .filter-bar { grid-template-columns: 1fr; }

  .calendar-grid { grid-template-columns: repeat(7, 1fr); gap: 2px; }
  .calendar-day { min-height: 60px; padding: 4px; font-size: 10px; }
  .calendar-day .day-num { font-size: 12px; }
}

/* Mobile phones */
@media (max-width: 600px) {
  .main { padding: 12px; }
  .page-header { flex-direction: column; gap: 10px; }
  .page-title { font-size: 20px; }

  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  .card { padding: 14px; border-radius: 14px; }
  .stat-value { font-size: 20px; }
  .punch-time { font-size: 24px; }
  .section-title { font-size: 16px; }

  /* Tables: horizontal scroll on all tables */
  table { font-size: 13px; }
  th, td { padding: 10px 8px; }

  /* User chip compact */
  .user-chip { padding: 4px 12px 4px 4px; }
  .user-chip div[style*="text-align"] { max-width: 140px; }

  /* Tabs scroll */
  .tab { padding: 10px 16px; font-size: 13px; }

  /* Login card */
  .login-card { padding: 32px 24px; border-radius: 18px; }
  .login-card h1 { font-size: 20px; }

  /* Announcements */
  .announcement-strip { padding: 10px 14px; font-size: 13px; }

  /* Buttons stack */
  .top-actions { flex-wrap: wrap; }
  .btn { font-size: 13px; padding: 10px 14px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }

  /* Pills */
  .pill { padding: 4px 8px; font-size: 11px; }

  /* Calendar: single column list on small phones */
  .calendar-grid { grid-template-columns: repeat(7, 1fr); gap: 1px; }
  .calendar-header { font-size: 10px; padding: 4px 2px; }
  .calendar-day { min-height: 45px; padding: 2px; font-size: 9px; border-radius: 4px; }
  .calendar-day .day-num { font-size: 11px; }
  .calendar-leave-tag { font-size: 8px; padding: 1px 3px; }

  /* Profile photo section */
  .profile-header { flex-direction: column; text-align: center; }

  /* Notice forms */
  .notice-actions { flex-direction: column; }
}

/* Very small phones */
@media (max-width: 400px) {
  .main { padding: 8px; }
  .card { padding: 12px; border-radius: 12px; }
  .page-title { font-size: 18px; }
  .brand { padding: 12px; gap: 10px; }
  .brand-logo { width: 42px; height: 42px; }
  .brand h1 { font-size: 15px; }
  .stat-value { font-size: 18px; }
  .mini-card { padding: 10px; }
}
