:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211b;
  background: #f3f6f3;
  --green: #178047;
  --green-dark: #11663a;
  --muted: #66736b;
  --line: #dce4de;
  --danger: #c83e3e;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.dashboard-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 44px 0 72px;
}

.heading, .settings-heading, .records-heading, .records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.heading { align-items: end; margin-bottom: 24px; }
.eyebrow, .section-label {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
}
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(30px, 4vw, 48px); }
h2 { font-size: 21px; }
.heading p:last-child, .records-heading p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
}

.header-actions { display: flex; align-items: center; gap: 9px; }
.header-actions form { margin: 0; }
.refresh, .logout-button, .save-button, .login-button,
.danger-button, .secondary-button, .danger-ghost {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 750;
  cursor: pointer;
}
.refresh, .save-button, .login-button {
  border: 0;
  color: #fff;
  background: var(--green);
  text-decoration: none;
}
.refresh { display: inline-flex; align-items: center; padding: 9px 15px; }
.refresh:hover, .save-button:hover, .login-button:hover { background: var(--green-dark); }
.logout-button, .secondary-button {
  padding: 9px 15px;
  border: 1px solid #cfd9d2;
  color: #435248;
  background: #fff;
}
.logout-button:hover, .secondary-button:hover { background: #f4f7f5; }
.nav-link { display: inline-flex; align-items: center; text-decoration: none; }

.settings-panel, .records-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(20, 46, 30, .06);
}
.settings-panel { margin-bottom: 22px; padding: 22px; }
.settings-heading { align-items: end; margin-bottom: 16px; }
.settings-heading p:last-child { margin: 8px 0 0; color: var(--muted); }
.redirect-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.redirect-field { min-width: 0; }
.field { display: grid; gap: 7px; }
.field > span { color: #4d5d53; font-size: 13px; font-weight: 700; }
.field input, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cfd9d2;
  border-radius: 10px;
  color: #17211b;
  background: #fbfcfb;
  outline: none;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 128, 71, .12);
}
.save-button {
  min-height: 46px;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 750;
}
.save-button { cursor: pointer; }
.save-button:disabled { opacity: .55; cursor: wait; }
.redirect-help { grid-column: 1 / -1; margin: -2px 0 0; color: #78857c; font-size: 12px; }
.route-rows { display: grid; gap: 12px; }
.route-row {
  display: grid;
  grid-template-columns: minmax(180px, .65fr) minmax(280px, 1.35fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #e1e8e3;
  border-radius: 13px;
  background: #fafcfb;
}
.route-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.route-actions .secondary-button, .route-actions .save-button { min-height: 46px; }
.login-error {
  padding: 11px 13px;
  border: 1px solid #f2c9c9;
  border-radius: 9px;
  color: #a13232;
  background: #fff5f5;
  font-size: 14px;
}

.records-section { overflow: hidden; }
.records-heading { padding: 22px 22px 14px; }
.records-toolbar {
  min-height: 58px;
  padding: 10px 22px;
  border-top: 1px solid #edf0ee;
  background: #f9fbf9;
}
.select-all-control { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; cursor: pointer; }
.select-all-control input, .row-select { width: 19px; height: 19px; accent-color: var(--green); cursor: pointer; }
.bulk-actions { display: flex; align-items: center; gap: 12px; }
#selectedCount { color: var(--muted); font-size: 13px; font-weight: 650; }
.danger-button {
  padding: 9px 15px;
  border: 0;
  color: #fff;
  background: var(--danger);
}
.danger-button:hover:not(:disabled) { background: #a92f2f; }
.danger-button:disabled, .login-button:disabled { opacity: .45; cursor: not-allowed; }

.table-wrap { overflow: auto; border-top: 1px solid #edf0ee; }
table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 15px; border-bottom: 1px solid #edf0ee; text-align: left; vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #4d5d53;
  background: #f8faf8;
  font-size: 12px;
  letter-spacing: .04em;
  white-space: nowrap;
}
tbody tr:hover { background: #f8fbf9; }
tbody tr:last-child td { border-bottom: 0; }
.checkbox-heading, .select-cell { width: 48px; text-align: center; }
.ip-value, .coordinate {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}
.entry-path { color: #355d43; white-space: nowrap; }
.ip-value { padding: 5px 8px; border-radius: 7px; color: #275c3d; background: #edf7f0; white-space: nowrap; }
.ip-location { min-width: 175px; color: #36463b; }
.loading-text { color: #8b978f; }
.js-local-time { white-space: nowrap; }
.danger-ghost {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid #efc6c6;
  color: #ae3535;
  background: #fff8f8;
}
.danger-ghost:hover { border-color: #dc8585; background: #fff0f0; }

.map-preview {
  display: grid;
  grid-template-columns: 74px auto;
  align-items: center;
  width: 168px;
  overflow: hidden;
  border: 1px solid #d5e0d8;
  border-radius: 10px;
  color: #245438;
  background: #fff;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.map-preview:hover { border-color: #70aa83; box-shadow: 0 8px 20px rgba(20, 70, 40, .12); transform: translateY(-1px); }
.mini-map {
  position: relative;
  display: block;
  height: 54px;
  overflow: hidden;
  background-color: #e8f0e9;
  background-image: linear-gradient(rgba(255,255,255,.55) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.55) 1px, transparent 1px);
  background-size: 18px 18px;
}
.map-road { position: absolute; display: block; width: 100px; height: 7px; border: 2px solid #fff; border-right: 0; border-left: 0; background: #cbd8cd; }
.road-one { top: 15px; left: -14px; transform: rotate(18deg); }
.road-two { top: 26px; left: -8px; transform: rotate(-36deg); }
.map-pin {
  position: absolute; top: 16px; left: 33px; width: 14px; height: 14px;
  border: 3px solid #fff; border-radius: 50% 50% 50% 0; background: #e94848;
  box-shadow: 0 3px 8px rgba(91,28,28,.3); transform: rotate(-45deg);
}
.map-label { padding: 0 9px; text-align: center; }
.empty { padding: 64px; color: #7d8981; text-align: center; }
.timezone-note { margin: 12px 4px 0; color: #78857c; font-size: 12px; }

.confirm-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 26px;
  border: 0;
  border-radius: 18px;
  color: #17211b;
  background: #fff;
  box-shadow: 0 24px 80px rgba(18, 31, 23, .28);
}
.confirm-dialog::backdrop { background: rgba(15, 25, 19, .55); backdrop-filter: blur(3px); }
.dialog-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 16px;
  border-radius: 50%; color: #b53131; background: #ffeded; font-size: 22px; font-weight: 850;
}
.confirm-dialog h2 { font-size: 24px; }
.confirm-dialog p { margin: 10px 0 22px; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions button { width: 100%; min-height: 46px; }
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 20;
  max-width: calc(100% - 28px); padding: 12px 17px; border-radius: 11px;
  color: #fff; background: #183d29; box-shadow: 0 12px 34px rgba(13, 35, 22, .28);
  opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: .18s ease;
}
.toast[data-type="error"] { background: #a93434; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, rgba(86, 177, 116, .22), transparent 30%),
    radial-gradient(circle at 92% 90%, rgba(92, 150, 111, .14), transparent 28%),
    #eef4ef;
}
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
.login-card {
  width: min(440px, 100%); padding: clamp(28px, 6vw, 42px); border: 1px solid rgba(205, 220, 210, .9);
  border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(25, 65, 39, .13);
}
.brand-mark { position: relative; width: 54px; height: 54px; margin-bottom: 25px; border-radius: 17px; background: var(--green); box-shadow: 0 10px 24px rgba(23,128,71,.25); }
.brand-mark::before { content: ""; position: absolute; inset: 13px; border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.brand-mark span { position: absolute; top: 24px; left: 24px; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.login-card h1 { font-size: clamp(30px, 8vw, 40px); }
.login-intro { margin: 10px 0 24px; color: var(--muted); }
.login-error { margin-bottom: 17px; line-height: 1.5; }
.login-form { display: grid; gap: 16px; }
.login-form input { min-height: 50px; font-size: 16px; }
.login-button { min-height: 50px; margin-top: 4px; font-size: 16px; }
.login-security { margin: 20px 0 0; color: #7b8980; font-size: 12px; text-align: center; }
.login-security span { color: var(--green); }

@media (max-width: 900px) {
  .redirect-form { grid-template-columns: 1fr auto; }
  .redirect-field { grid-column: 1 / -1; }
  .route-row { grid-template-columns: 1fr 1fr; }
  .route-row .remove-route { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .dashboard-shell { width: min(100% - 24px, 1480px); padding: 26px 0 calc(96px + env(safe-area-inset-bottom)); }
  .heading { align-items: start; flex-direction: column; margin-bottom: 18px; }
  .header-actions { width: 100%; }
  .header-actions .refresh, .header-actions form, .header-actions .logout-button { flex: 1; width: 100%; justify-content: center; text-align: center; }
  .settings-panel { padding: 18px; }
  .settings-heading { align-items: start; }
  .redirect-form { grid-template-columns: 1fr 1fr; }
  .save-button { grid-column: 1 / -1; width: 100%; min-height: 48px; }
  .route-row { grid-template-columns: 1fr; }
  .route-row .remove-route { grid-column: auto; width: 100%; }
  .route-actions { display: grid; grid-template-columns: 1fr; }
  .records-heading { padding: 19px 18px 13px; }
  .records-toolbar {
    position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 8;
    margin: 0 10px 10px; padding: 10px 12px; border: 1px solid #d9e3dc; border-radius: 13px;
    background: rgba(249,251,249,.96); box-shadow: 0 12px 34px rgba(18,48,29,.16); backdrop-filter: blur(10px);
  }
  .bulk-actions { gap: 8px; }
  #selectedCount { display: none; }
  .danger-button { min-height: 42px; }
  .table-wrap { overflow: visible; border-top: 1px solid #edf0ee; background: #f3f6f3; }
  table, tbody { display: block; min-width: 0; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; padding: 12px; }
  tbody tr:not(.empty-row) {
    display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 0 10px;
    padding: 16px 15px; border: 1px solid #dce4de; border-radius: 15px; background: #fff;
    box-shadow: 0 7px 20px rgba(20,46,30,.05);
  }
  tbody tr:hover { background: #fff; }
  tbody td {
    grid-column: 2; display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px;
    align-items: start; min-width: 0; padding: 9px 0; border: 0; border-bottom: 1px solid #eff2f0;
  }
  tbody td::before { content: attr(data-label); color: #7a877e; font-size: 12px; font-weight: 700; }
  tbody .select-cell { grid-column: 1; grid-row: 1 / span 8; display: block; padding-top: 8px; text-align: left; }
  tbody .select-cell::before { display: none; }
  tbody .map-cell, tbody .action-cell { border-bottom: 0; }
  .ip-location { min-width: 0; }
  .js-local-time { white-space: normal; }
  .map-preview { width: 100%; max-width: 230px; }
  .action-cell .danger-ghost { width: 100%; min-height: 42px; }
  .empty-row { display: block; }
  .empty { display: block; padding: 48px 18px; border: 0; background: #fff; }
  .empty::before { display: none; }
  .timezone-note { padding: 0 4px; }
}

@media (max-width: 420px) {
  .records-toolbar { align-items: center; }
  .select-all-control { font-size: 14px; }
  .bulk-actions .danger-button { padding-inline: 12px; }
  .confirm-dialog { width: calc(100% - 20px); margin: auto 10px max(10px, env(safe-area-inset-bottom)); border-radius: 20px; }
}
