:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e4e7ee;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #1e4fd8;
  --primary-dark: #1840b3;
  --primary-soft: #e8eefd;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --info-soft: #cffafe;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ============== LAYOUT ============== */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 16px;
}

.sidebar .brand .logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.sidebar .brand .title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

.sidebar .brand .subtitle {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
}

.sidebar .nav-section {
  padding: 12px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: #475569;
  letter-spacing: 0.5px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar nav a:hover {
  background: #1e293b;
  color: #fff;
  text-decoration: none;
}

.sidebar nav a.active {
  background: #1e293b;
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar nav a .icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  opacity: 0.8;
}

.sidebar .user-card {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .user-card .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.sidebar .user-card .name { color: #fff; font-size: 13px; font-weight: 500; }
.sidebar .user-card .role { color: #64748b; font-size: 11px; }

/* topbar */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.topbar .crumbs {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar .actions { display: flex; gap: 10px; align-items: center; }

.bell {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}
.bell::after {
  content: "3";
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.content { padding: 24px 28px; }

/* ============== COMPONENTS ============== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #f9fafb; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card .card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.card .card-body { padding: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
}
.stat-card .delta {
  font-size: 12px;
  margin-top: 6px;
  color: var(--success);
}
.stat-card .icon-bg {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  float: right;
  margin-top: -56px;
  font-size: 18px;
  font-weight: 700;
}

/* tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.4px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: #f3f4f6; color: var(--muted); }

/* form */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* avatar */
.avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  margin-right: 6px;
}

.user-cell {
  display: flex;
  align-items: center;
}
.user-cell .name { font-weight: 500; }
.user-cell .sub { color: var(--muted); font-size: 12px; }

/* search */
.search-box {
  position: relative;
  display: inline-block;
}
.search-box input {
  padding-left: 34px;
  width: 280px;
}
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.5;
}

/* filters bar */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters select, .filters input { width: auto; }

/* ============== LOGIN ============== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.login-hero {
  background: linear-gradient(135deg, #1e4fd8 0%, #0f172a 100%);
  color: #fff;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: "";
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.login-hero::after {
  content: "";
  position: absolute;
  bottom: -150px; left: -50px;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}
.login-hero .brand-big {
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.login-hero .brand-big .logo {
  width: 48px; height: 48px;
  background: #fff;
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
}
.login-hero .brand-big .title { font-size: 16px; font-weight: 600; }
.login-hero .brand-big .subtitle { font-size: 12px; opacity: 0.7; }

.login-hero .pitch {
  position: relative;
  z-index: 1;
}
.login-hero .pitch h2 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 16px;
  line-height: 1.2;
}
.login-hero .pitch p {
  font-size: 15px;
  opacity: 0.85;
  line-height: 1.6;
  max-width: 440px;
}
.login-hero .features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}
.login-hero .features .feat {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}
.login-hero .features .feat .check {
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.login-hero .footer-note {
  font-size: 12px;
  opacity: 0.5;
  position: relative;
  z-index: 1;
}

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-form {
  width: 100%;
  max-width: 380px;
}
.login-form h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}
.login-form .lead {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 14px;
}
.login-form .row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 20px;
}
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
}
.divider {
  text-align: center;
  margin: 24px 0;
  position: relative;
  color: var(--muted);
  font-size: 12px;
}
.divider::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: var(--border);
  z-index: 0;
}
.divider span {
  background: var(--bg);
  padding: 0 12px;
  position: relative;
  z-index: 1;
}

/* ============== CALENDAR ============== */
.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-nav button {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.cal-nav .month-label { font-weight: 600; min-width: 160px; text-align: center; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-grid .dow {
  padding: 10px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}
.cal-grid .day {
  min-height: 110px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  background: #fff;
}
.cal-grid .day:nth-child(7n+7) { border-right: none; }
.cal-grid .day.muted { background: #fafbfd; color: var(--muted); }
.cal-grid .day.today { background: var(--primary-soft); }
.cal-grid .day .num { font-size: 13px; font-weight: 600; }
.cal-grid .day .pill {
  display: block;
  margin-top: 4px;
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-grid .day .pill.warn { background: var(--warning-soft); color: var(--warning); }
.cal-grid .day .pill.success { background: var(--success-soft); color: var(--success); }

/* ============== DETAIL ============== */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 20px;
  font-size: 13px;
}
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 500; }

.assigned-list { list-style: none; padding: 0; margin: 0; }
.assigned-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.assigned-list li:last-child { border-bottom: none; }
.assigned-list .person {
  display: flex; gap: 10px; align-items: center;
}
.assigned-list .avatar-md {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
}
.assigned-list .person .name { font-weight: 500; }
.assigned-list .person .sub { color: var(--muted); font-size: 12px; }

/* worker card list */
.task-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  border-left: 4px solid var(--primary);
}
.task-card.done { border-left-color: var(--success); opacity: 0.85; }
.task-card.urgent { border-left-color: var(--warning); }
.task-card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.task-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.task-card .addr {
  color: var(--muted);
  font-size: 12px;
}
.task-card .meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
  font-size: 12px;
}
.task-card .meta .lbl { color: var(--muted); margin-bottom: 2px; }
.task-card .meta .val { font-weight: 500; }
.task-card .members {
  display: flex;
  margin-top: 12px;
}
.task-card .members .avatar-sm:not(:first-child) {
  margin-left: -8px;
  border: 2px solid #fff;
}
.task-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tabs a {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.tabs a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tabs a:hover { color: var(--text); text-decoration: none; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative;
  padding: 0 0 16px 28px;
  border-left: 2px solid var(--border);
  margin-left: 8px;
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--primary);
}
.timeline .when { font-size: 11px; color: var(--muted); }
.timeline .what { font-size: 13px; margin-top: 2px; }

/* small helpers */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .task-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}
