/* ============ LGP Tracker styles ============ */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #1c2433;
  --text-soft: #64708a;
  --primary: #2056c7;
  --primary-dark: #17409a;
  --primary-soft: #e8effc;
  --green: #1d9a6c;
  --green-soft: #e3f6ee;
  --amber: #c77700;
  --amber-soft: #fdf1dd;
  --red: #d6354a;
  --red-soft: #fdebed;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(28, 36, 51, 0.07), 0 4px 14px rgba(28, 36, 51, 0.05);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button { font-family: inherit; }

.app-shell { display: contents; }

/* ============ Login ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14213d 0%, #1e3a6e 50%, #2056c7 100%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .brand-icon { font-size: 42px; margin-bottom: 8px; }
.login-brand h1 { margin: 0 0 4px; font-size: 22px; color: var(--text); }
.login-brand p { margin: 0; color: var(--text-soft); font-size: 13px; }

.btn-block { width: 100%; justify-content: center; margin-top: 4px; }
.login-hint { text-align: center; font-size: 11.5px; margin: 18px 0 0; }

/* ============ Sidebar user ============ */
.sidebar-user {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user-name { font-weight: 700; font-size: 13.5px; color: #fff; }
.sidebar-user-role { font-size: 11px; color: #8fa3c8; margin: 2px 0 10px; }

.admin-only.hidden-by-role { display: none !important; }

.badge-role-admin { background: #e8effc; color: var(--primary); }
.badge-role-handler { background: var(--green-soft); color: var(--green); }

/* ============ Sidebar ============ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #14213d;
  color: #dbe4f5;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.brand-icon { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 17px; color: #fff; }
.brand-sub { font-size: 11px; color: #8fa3c8; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: #c3cfe6;
  font-size: 14.5px;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e80a3;
  padding: 12px 12px 4px;
}

.nav-sub { padding-left: 24px; }

.nav-badge {
  margin-left: auto;
  background: var(--amber);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 14px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: #6e80a3;
  padding: 8px;
  line-height: 1.5;
}

/* ============ Main layout ============ */
.main {
  margin-left: var(--sidebar-w);
  padding: 28px 32px 60px;
  max-width: 1280px;
}

.view.hidden { display: none; }
.hidden { display: none !important; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-header h1 { margin: 0 0 4px; font-size: 24px; }
.page-sub { margin: 0; color: var(--text-soft); font-size: 13.5px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Buttons ============ */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-light {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-light:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b02438; }

.btn-small { padding: 6px 11px; font-size: 12.5px; }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 30px; height: 30px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
}
.btn-icon:hover { background: var(--primary-soft); }

/* ============ KPI cards ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(28, 36, 51, 0.12); }
.kpi-customers { cursor: default; }

.kpi-active   { border-top-color: var(--green); }
.kpi-expiring { border-top-color: var(--amber); }
.kpi-expired  { border-top-color: var(--red); }
.kpi-customers{ border-top-color: var(--primary); }

.kpi-label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.kpi-value { font-size: 34px; font-weight: 800; margin: 6px 0 2px; }
.kpi-active   .kpi-value { color: var(--green); }
.kpi-expiring .kpi-value { color: var(--amber); }
.kpi-expired  .kpi-value { color: var(--red); }
.kpi-customers .kpi-value { color: var(--primary); }
.kpi-hint { font-size: 12px; color: var(--text-soft); }

/* ============ Dashboard grid & cards ============ */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.span-2 { grid-column: 1 / -1; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header h2 { margin: 0; font-size: 16.5px; }
.card-sub { font-size: 12.5px; color: var(--text-soft); }

/* ============ Calendar ============ */
.calendar-controls { display: flex; align-items: center; gap: 10px; }
.cal-title { font-weight: 700; font-size: 14px; min-width: 130px; text-align: center; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  padding: 4px 0;
  text-transform: uppercase;
}

.cal-day {
  position: relative;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 12.5px;
  background: #fbfcfe;
  cursor: default;
}

.cal-day.out { opacity: 0.35; }
.cal-day.today { border-color: var(--primary); border-width: 2px; font-weight: 700; }
.cal-day.has-expiry { cursor: pointer; }
.cal-day.has-expiry:hover { background: var(--primary-soft); }

.cal-badge {
  position: absolute;
  bottom: 5px;
  right: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
}

.cal-badge.b-active   { background: var(--green); }
.cal-badge.b-expiring { background: var(--amber); }
.cal-badge.b-expired  { background: var(--red); }

.calendar-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-soft);
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-active { background: var(--green); }
.dot-expiring { background: var(--amber); }
.dot-expired { background: var(--red); }

.cal-day-detail {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  font-size: 13px;
}

.cal-day-detail h3 { margin: 0 0 8px; font-size: 13.5px; }

/* ============ Mini list (upcoming) ============ */
.mini-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.mini-item-main { min-width: 0; }
.mini-item-title { font-weight: 700; font-size: 13.5px; }
.mini-item-sub { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item-right { text-align: right; flex-shrink: 0; }
.mini-days { font-size: 12px; font-weight: 700; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafd; }
.th-actions { text-align: right; }
.td-actions { text-align: right; white-space: nowrap; }

.td-remarks { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Status badges ============ */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

.badge-active   { background: var(--green-soft); color: var(--green); }
.badge-expiring { background: var(--amber-soft); color: var(--amber); }
.badge-expired  { background: var(--red-soft);  color: var(--red); }

.days-pos { color: var(--green); font-weight: 700; }
.days-warn { color: var(--amber); font-weight: 700; }
.days-neg { color: var(--red); font-weight: 700; }

/* ============ Filters ============ */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-input { flex: 1; min-width: 240px; }

.filters select.input { width: auto; min-width: 170px; flex: 0 0 auto; }

/* ============ Forms ============ */
.form-card { max-width: 860px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.span-full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.req { color: var(--red); }
.muted { color: var(--text-soft); font-weight: 400; }

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(32, 86, 199, 0.15);
}

select.input { cursor: pointer; }
textarea.input { resize: vertical; }

.field-error { font-size: 12px; color: var(--red); margin-top: 4px; min-height: 14px; }

.auto-fields {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--primary-soft);
  border: 1px dashed var(--primary);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0;
}

.auto-label { display: block; font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.auto-value { font-size: 16px; font-weight: 800; }
.auto-note { font-size: 12.5px; color: var(--text-soft); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ============ Reminder banner ============ */
.reminder-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: #7a4b00;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 13.5px;
}

.banner-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: inherit;
}

/* ============ Misc ============ */
.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 36px 10px;
  font-size: 14px;
}

.danger-zone { margin-top: 18px; }
.danger-zone h2 { margin: 0 0 6px; font-size: 16px; }
.danger-zone p { margin: 0 0 14px; font-size: 13px; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2433;
  color: #fff;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ Filter labels & report toolbar ============ */
.filter-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

.filter-label .input { width: auto; min-width: 160px; }

.filters { align-items: flex-end; }
.filters-spacer { flex: 1; }

.report-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  padding-bottom: 10px;
}

#clearFiltersBtn { margin-bottom: 2px; }

/* ============ File inputs & attachments ============ */
.input-readonly { background: #f4f6fa; cursor: default; }

.input-file { padding: 7px 10px; cursor: pointer; }
.input-file::file-selector-button {
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 6px;
  padding: 5px 10px;
  font-weight: 600;
  font-size: 12.5px;
  margin-right: 10px;
  cursor: pointer;
}

.attachment-list { display: flex; flex-direction: column; gap: 8px; }

.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.attachment-icon { font-size: 16px; }
.attachment-name {
  font-weight: 600;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-meta { color: var(--text-soft); font-size: 12px; margin-right: auto; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 61, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-note { font-size: 12.5px; margin: 14px 0; }

/* ============ Notifications ============ */
.notif-card-gap { margin-top: 16px; }

.auto-log-lines { max-height: 300px; overflow-y: auto; }

.auto-log-line {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: var(--text-soft);
  padding: 5px 2px;
  border-bottom: 1px dashed var(--border);
  word-break: break-word;
}

.settings-h2 { margin: 0 0 8px; font-size: 16px; }

.setup-steps {
  font-size: 13px;
  line-height: 1.7;
  padding-left: 20px;
  margin: 8px 0 0;
}

.scheduler-form { margin-top: 16px; }

.scheduler-row { margin-bottom: 14px; }

.scheduler-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.scheduler-toggle input { width: 18px; height: 18px; cursor: pointer; }

.scheduler-grid { margin-top: 4px; }

.scheduler-hint {
  font-size: 13px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.scheduler-actions { margin-top: 16px; gap: 10px; }

.scheduler-status {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.sched-badge { font-weight: 700; }
.sched-on { color: var(--green); }
.sched-off { color: var(--amber); }

.input-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg);
}

/* ============ Responsive ============ */
@media (max-width: 980px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
  }
  .brand { border: none; padding: 0; margin: 0 16px 0 0; }
  .brand-sub, .sidebar-footer { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { margin-left: 0; padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
}
