/* ============ ANITA TORIM — Medical CRM ============ */
:root {
  --teal-900: #0b3b3c;
  --teal-800: #0e4f50;
  --teal-700: #0f6e6b;
  --teal-600: #128a84;
  --teal-100: #d9f0ee;
  --teal-50:  #eef8f7;
  --mint-bg:  #f4faf9;
  --ink:      #14262b;
  --ink-soft: #4b5f64;
  --line:     #dbe8e6;
  --card:     #ffffff;
  --coral:    #e4573d;
  --coral-bg: #fdeee9;
  --amber:    #d9930d;
  --amber-bg: #fdf4e0;
  --ok:       #1f9d6d;
  --ok-bg:    #e4f6ee;
  --seg-a:    #0f6e6b;
  --seg-b:    #2f7fb6;
  --seg-c:    #8a67c8;
  --seg-n:    #8b9aa0;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(11,59,60,.06), 0 8px 24px -12px rgba(11,59,60,.14);
  --font: 'Heebo', system-ui, sans-serif;
  --font-display: 'Secular One', 'Heebo', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(18,138,132,.10), transparent 60%),
    radial-gradient(900px 400px at -10% 15%, rgba(47,127,182,.07), transparent 55%),
    var(--mint-bg);
  min-height: 100vh; line-height: 1.55;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: .95rem; color: var(--ink); }

/* ---------- Boot ---------- */
.at-boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--ink-soft); }
.at-boot-logo { font-family: var(--font-display); font-size: 2rem; color: var(--teal-800); letter-spacing: .04em; }
.at-boot-logo span { color: var(--coral); margin-inline-start: .35rem; }
.at-boot-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--teal-100); border-top-color: var(--teal-600); animation: at-spin 0.8s linear infinite; }
@keyframes at-spin { to { transform: rotate(360deg); } }

/* ---------- Shell ---------- */
.at-shell { max-width: 1240px; margin: 0 auto; padding: 20px 18px 90px; }
.at-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.at-brand { font-family: var(--font-display); font-size: 1.55rem; color: var(--teal-800); line-height: 1.1; }
.at-brand small { display: block; font-family: var(--font); font-size: .78rem; font-weight: 400; color: var(--ink-soft); letter-spacing: .02em; }
.at-greeting { font-size: 1.05rem; color: var(--teal-900); }
.at-greeting b { font-weight: 600; }
.at-greeting .at-howru { display: block; font-size: .85rem; color: var(--ink-soft); }
.at-savestate { font-size: .78rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.at-savestate .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.at-savestate.saving .dot { background: var(--amber); animation: at-pulse 1s infinite; }
.at-savestate.error .dot { background: var(--coral); }
@keyframes at-pulse { 50% { opacity: .35; } }

/* ---------- Tabs ---------- */
.at-tabs { display: flex; gap: 6px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px; box-shadow: var(--shadow); position: sticky; top: 10px; z-index: 40; }
.at-tab { border: 0; background: transparent; padding: 9px 16px; border-radius: 999px; font-size: .95rem; font-weight: 500; color: var(--ink-soft); cursor: pointer; transition: background .15s, color .15s; }
.at-tab:hover { background: var(--teal-50); color: var(--teal-800); }
.at-tab.active { background: var(--teal-700); color: #fff; }
.at-tab .count { font-size: .72rem; background: rgba(255,255,255,.22); border-radius: 999px; padding: 1px 7px; margin-inline-start: 6px; }
.at-tab:not(.active) .count { background: var(--teal-100); color: var(--teal-800); }

.at-view { margin-top: 18px; animation: at-in .25s ease; }
@keyframes at-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Cards & layout ---------- */
.at-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; }
.at-card + .at-card { margin-top: 14px; }
.at-card h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 600; color: var(--teal-900); }
.at-card h2 .hint, .at-hint { font-size: .82rem; color: var(--ink-soft); font-weight: 400; }
.at-grid { display: grid; gap: 14px; }
.at-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.at-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.at-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) { .at-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .at-grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .at-grid.cols-4, .at-grid.cols-3, .at-grid.cols-2 { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.at-kpi { position: relative; overflow: hidden; }
.at-kpi .num { font-family: var(--font-display); font-size: 2.1rem; color: var(--teal-800); line-height: 1.05; }
.at-kpi .lbl { font-size: .85rem; color: var(--ink-soft); }
.at-kpi.warn .num { color: var(--coral); }
.at-kpi .spark { position: absolute; inset-inline-end: -18px; top: -18px; width: 90px; height: 90px; border-radius: 50%; background: var(--teal-50); z-index: 0; }
.at-kpi.warn .spark { background: var(--coral-bg); }
.at-kpi > * { position: relative; z-index: 1; }

.at-progress { height: 10px; border-radius: 999px; background: var(--teal-50); overflow: hidden; border: 1px solid var(--line); }
.at-progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-600), var(--teal-700)); border-radius: 999px; transition: width .4s ease; }
.at-progress.warn > i { background: linear-gradient(90deg, #f0876f, var(--coral)); }

/* ---------- Chips / badges ---------- */
.at-seg { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 8px; color: #fff; font-weight: 600; font-size: .8rem; }
.at-seg.A { background: var(--seg-a); } .at-seg.B { background: var(--seg-b); }
.at-seg.C { background: var(--seg-c); } .at-seg.N { background: var(--seg-n); }
.at-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.at-badge.hosp { background: var(--teal-100); color: var(--teal-900); border-color: #c4e4e1; }
.at-badge.clinic { background: #eef2f6; color: #3d5560; border-color: #dde6ec; }
.at-badge.behind { background: var(--coral-bg); color: #b23c26; border-color: #f6cfc4; }
.at-badge.ontrack { background: var(--ok-bg); color: #157a53; border-color: #c4ead8; }
.at-badge.done { background: var(--ok-bg); color: #157a53; border-color: #c4ead8; }
.at-badge.zero { background: #f1f3f4; color: #7d8b90; border-color: #e2e7e8; }
.at-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--teal-50); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: .84rem; }
.at-chip button { border: 0; background: var(--teal-100); color: var(--teal-900); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: .7rem; line-height: 1; }
.at-waze { display: inline-flex; align-items: center; gap: 3px; font-size: .7rem; font-weight: 600; color: #0a7fa8; background: #e4f6fd; border: 1px solid #bfe8f7; border-radius: 999px; padding: 1px 8px; text-decoration: none; margin-inline-start: 4px; vertical-align: middle; transition: background .15s; }
.at-waze::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #05c8f7; }
.at-waze:hover { background: #d2f0fc; }

/* ---------- Buttons ---------- */
.at-btn { border: 1px solid var(--line); background: #fff; color: var(--teal-900); border-radius: var(--r-sm); padding: 8px 14px; font-size: .9rem; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; display: inline-flex; align-items: center; gap: 7px; }
.at-btn:hover { background: var(--teal-50); border-color: #c6dedb; }
.at-btn:active { transform: translateY(1px); }
.at-btn.primary { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.at-btn.primary:hover { background: var(--teal-800); }
.at-btn.danger { color: #b23c26; }
.at-btn.danger:hover { background: var(--coral-bg); border-color: #f0c3b6; }
.at-btn.ghost { border-color: transparent; background: transparent; }
.at-btn.ghost:hover { background: var(--teal-50); }
.at-btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.at-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Filters bar ---------- */
.at-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.at-filters .grow { flex: 1 1 220px; }
.at-input, .at-select, .at-date, .at-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.at-input:focus, .at-select:focus, .at-date:focus, .at-textarea:focus { border-color: var(--teal-600); box-shadow: 0 0 0 3px rgba(18,138,132,.14); }
.at-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234b5f64' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-inline-start: 30px; }
.at-inline-select { width: auto; }
.at-textarea { resize: vertical; min-height: 64px; }

/* ---------- Table ---------- */
.at-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
table.at-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 900px; }
.at-table th { text-align: right; font-weight: 600; font-size: .8rem; color: var(--ink-soft); background: var(--teal-50); padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; white-space: nowrap; }
.at-table th.sortable { cursor: pointer; user-select: none; }
.at-table th.sortable:hover { color: var(--teal-800); }
.at-table td { padding: 9px 12px; border-bottom: 1px solid #ecf3f2; vertical-align: top; }
.at-table tbody tr:hover { background: #f7fbfa; }
.at-table tr.behind-row { background: #fff8f6; }
.at-table tr.behind-row:hover { background: #fdf0ec; }
.at-table .name { font-weight: 600; color: var(--teal-900); }
.at-table .sub { font-size: .78rem; color: var(--ink-soft); }
.at-table .locline { font-size: .8rem; color: var(--ink-soft); max-width: 420px; }
.at-count { font-size: .82rem; color: var(--ink-soft); margin: 8px 2px; }
.at-met-x { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Plan (schedule) ---------- */
.at-planbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.at-days { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.at-day { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.at-day-head { padding: 12px 14px; background: linear-gradient(135deg, var(--teal-50), #fff); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.at-day.hospital .at-day-head { background: linear-gradient(135deg, var(--teal-100), #f3fbfa); }
.at-day-title { font-weight: 600; color: var(--teal-900); }
.at-day-title small { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-soft); }
.at-day-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.at-day-foot { padding: 10px 12px; border-top: 1px dashed var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.at-planrow { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid #eaf2f1; border-radius: var(--r-sm); background: #fbfdfd; }
.at-planrow.done { background: var(--ok-bg); border-color: #cdebdc; }
.at-planrow .info { flex: 1; min-width: 0; }
.at-planrow .info b { font-size: .9rem; }
.at-planrow .info small { display: block; font-size: .76rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.at-planrow input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--teal-700); cursor: pointer; flex: none; }
.at-planrow .rm { border: 0; background: none; color: #a4b3b8; cursor: pointer; font-size: 1rem; padding: 2px; }
.at-planrow .rm:hover { color: var(--coral); }
.at-day .cap { font-size: .76rem; }
.at-day .cap.over { color: var(--coral); font-weight: 600; }
.at-empty { text-align: center; color: var(--ink-soft); padding: 26px 10px; border: 2px dashed var(--line); border-radius: var(--r-md); background: #fbfdfd; }

/* ---------- Picker dropdown ---------- */
.at-picker { position: relative; flex: 1; min-width: 170px; }
.at-picker-list { position: absolute; top: calc(100% + 4px); inset-inline: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); max-height: 240px; overflow: auto; z-index: 60; }
.at-picker-item { padding: 8px 12px; cursor: pointer; font-size: .88rem; display: flex; justify-content: space-between; gap: 8px; }
.at-picker-item:hover { background: var(--teal-50); }
.at-picker-item small { color: var(--ink-soft); }

/* ---------- Meetings list ---------- */
.at-meet { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid #eef4f3; }
.at-meet:last-child { border-bottom: 0; }
.at-meet .when { flex: none; width: 96px; font-size: .82rem; color: var(--teal-800); font-weight: 600; }
.at-meet .what { flex: 1; }
.at-meet .note { font-size: .84rem; color: var(--ink-soft); white-space: pre-wrap; }

/* ---------- Settings ---------- */
.at-set-row { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
@media (max-width: 620px) { .at-set-row { grid-template-columns: 1fr; } }
.at-set-row label { font-weight: 600; font-size: .9rem; color: var(--teal-900); }
.at-groups { display: flex; flex-direction: column; gap: 10px; }
.at-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border: 1px dashed var(--line); border-radius: var(--r-md); padding: 10px; background: #fbfdfd; }
.at-current-q { font-size: .8rem; color: var(--teal-700); font-weight: 600; }

/* ---------- Modal ---------- */
.at-overlay { position: fixed; inset: 0; background: rgba(11,59,60,.35); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 100; animation: at-in .18s ease; }
.at-modal { width: min(760px, 100%); max-height: 88vh; overflow: auto; background: #fff; border-radius: var(--r-lg); box-shadow: 0 20px 60px -20px rgba(11,59,60,.45); padding: 20px; }
.at-locrow { display: grid; grid-template-columns: 120px 1fr 110px 1.4fr 1.1fr 34px; gap: 6px; align-items: center; margin-bottom: 6px; }
.at-locrow .at-input, .at-locrow .at-select { padding: 7px 9px; font-size: .85rem; }
@media (max-width: 680px) {
  .at-locrow { grid-template-columns: 1fr 1fr; border: 1px dashed var(--line); border-radius: var(--r-md); padding: 8px; }
  .at-locrow .l-addr, .at-locrow .l-sched { grid-column: 1 / -1; }
}
.at-modal h3 { margin: 0 0 12px; font-size: 1.1rem; color: var(--teal-900); }
.at-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.at-form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .at-form-grid { grid-template-columns: 1fr; } }
.at-field label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.at-modal-actions { display: flex; justify-content: flex-start; gap: 10px; margin-top: 16px; }

/* ---------- Toast ---------- */
.at-toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); background: var(--teal-900); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow); z-index: 200; animation: at-in .2s ease; }
[dir="rtl"] .at-toast { transform: translateX(50%); }

/* ---------- Login ---------- */
.at-login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.at-login { width: min(420px, 100%); }
.at-login-card { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 70px -28px rgba(11,59,60,.35); padding: 34px 30px 26px; text-align: center; animation: at-in .35s ease; }
.at-login-pulse { position: absolute; top: -70px; inset-inline-end: -70px; width: 190px; height: 190px; border-radius: 50%; background: radial-gradient(circle, rgba(18,138,132,.16), transparent 65%); animation: at-breathe 4s ease-in-out infinite; }
@keyframes at-breathe { 50% { transform: scale(1.18); } }
.at-login-card .at-boot-logo { font-size: 1.8rem; }
.at-login-hello { color: var(--teal-900); font-size: 1.05rem; margin: 10px 0 18px; }
.at-login-hello small { color: var(--ink-soft); font-size: .82rem; }
.at-login form { text-align: right; display: flex; flex-direction: column; gap: 6px; }
.at-login-label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-top: 8px; }
.at-login-remember { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-soft); margin: 12px 0 4px; cursor: pointer; }
.at-login-remember input { accent-color: var(--teal-700); width: 16px; height: 16px; }
.at-login-btn { justify-content: center; width: 100%; padding: 12px; font-size: 1rem; margin-top: 8px; }
.at-login-error { background: var(--coral-bg); color: #b23c26; border: 1px solid #f6cfc4; border-radius: var(--r-md); padding: 10px 14px; font-size: .88rem; margin-bottom: 14px; }
.at-login-forgot { display: inline-block; margin-top: 16px; font-size: .82rem; color: var(--teal-700); }

/* ---------- Misc ---------- */
.at-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.at-spread { justify-content: space-between; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.at-note-inline { font-size: .8rem; color: var(--ink-soft); }
.at-linklike { border: 0; background: none; color: var(--teal-700); cursor: pointer; text-decoration: underline; font-size: .84rem; padding: 0; }
@media (max-width: 620px) {
  .at-shell { padding: 12px 10px 80px; }
  .at-tabs { position: static; border-radius: var(--r-md); }
  .at-days { grid-template-columns: 1fr; }
  .at-topbar { align-items: flex-start; }
}
@media print {
  .at-tabs, .at-filters, .at-planbar, .at-btn, .at-savestate { display: none !important; }
  body { background: #fff; }
}
