:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-2: #eef5f3;
  --text: #17211f;
  --muted: #66736f;
  --line: #dce7e3;
  --accent: #0f8f7d;
  --accent-2: #ef775f;
  --danger: #c84d4d;
  --warning: #b7791f;
  --success: #247a4b;
  --shadow: 0 16px 45px rgba(35, 55, 50, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 14px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f9fbfa;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #132521;
  color: #d8e8e3;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 26px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a {
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #bcd0ca;
  font-size: 14px;
  font-weight: 650;
}

.sidebar nav a:hover,
.sidebar nav a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar,
.page-head,
.filters,
.quick-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.topbar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.page-head {
  justify-content: space-between;
  margin: 6px 0 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
}

.btn:hover {
  border-color: #b8cbc5;
}

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

.btn.ghost {
  background: var(--surface-2);
}

.btn.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn.danger {
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.plan-card {
  display: grid;
  gap: 10px;
}

.plan-card strong {
  font-size: 26px;
}

.filters {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters input,
.filters select {
  max-width: 260px;
}

.table-panel {
  overflow-x: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #edf2f7;
  color: #364152;
}

.badge.aktivan,
.badge.active,
.badge.sent {
  background: #e5f7ee;
  color: var(--success);
}

.badge.uskoro,
.badge.warning,
.badge.scheduled {
  background: #fff5df;
  color: var(--warning);
}

.badge.istekao,
.badge.suspendovan,
.badge.suspended,
.badge.failed,
.badge.cancelled,
.badge.inactive {
  background: #fdeaea;
  color: var(--danger);
}

.actions {
  align-items: flex-start;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.inline-form {
  display: flex;
  gap: 6px;
}

.inline-form input {
  width: 105px;
  min-height: 32px;
  padding: 6px 8px;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.check input {
  width: auto;
}

.phone-lookup-field,
.date-picker-row {
  position: relative;
}

.date-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.date-picker-row [data-date-picker-native] {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.patient-lookup-results {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.patient-lookup-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.patient-lookup-option:hover {
  background: #dfeeea;
}

.patient-lookup-option span {
  color: var(--muted);
  white-space: nowrap;
}

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
  background: #eef6ff;
  color: #28537a;
}

.alert.success {
  background: #e5f7ee;
  color: var(--success);
}

.alert.danger {
  background: #fdeaea;
  color: var(--danger);
}

.alert.warning {
  background: #fff5df;
  color: var(--warning);
}

.empty {
  color: var(--muted);
  margin: 0;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 24, 21, 0.45);
  padding: 24px;
  overflow-y: auto;
  z-index: 20;
}

.modal.is-open {
  display: grid;
  place-items: start center;
}

.modal-card {
  position: relative;
  width: min(720px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2);
}

.modal-card.large {
  width: min(920px, 100%);
}

.modal-card h2 {
  margin: 0 0 18px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
}

.sms-counter,
.confirm-box {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.confirm-box {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  background: #f9fbfa;
  border-radius: var(--radius);
  padding: 12px;
}

.manual-patients {
  max-height: 160px;
  overflow: auto;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 143, 125, 0.12), rgba(239, 119, 95, 0.08)),
    var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

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

.login-panel p {
  color: var(--muted);
  margin: 0 0 18px;
}

@media (max-width: 1100px) {
  .stats-grid,
  .cards-grid,
  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .cards-grid,
  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select {
    max-width: none;
  }

  .quick-actions {
    flex-wrap: wrap;
  }
}
