/* Kekthal Agent Dashboard — Trust Teal, self-contained */
:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #475569;
  --brand: #1d4ed8;
  --brand-soft: #eff6ff;
  --accent: #0d9488;
  --accent-soft: #f0fdfa;
  --line: #e2e8f0;
  --wa: #25D366;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: system-ui, "Noto Sans", "Noto Sans Devanagari", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-w: 240px;
  --bottom-h: 64px;
  --top-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-soft);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }

/* —— Login (outside shell) —— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--brand-soft) 0%, var(--accent-soft) 55%, #fff 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.login-logo {
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 4px;
  color: var(--ink);
  text-decoration: none;
}
.login-logo span { color: var(--accent); }
.login-logo:hover { text-decoration: none; }

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.login-card .field { margin-bottom: 14px; }

.login-card input[type="email"],
.login-card input[type="password"],
.login-card input[type="text"],
.login-card input[type="tel"],
.agent-form input,
.agent-form textarea,
.agent-form select,
.filter-bar input,
.filter-bar select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
.login-card input:focus,
.agent-form input:focus,
.agent-form textarea:focus,
.agent-form select:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 18px;
  font-size: 0.85rem;
}

.login-actions a { color: var(--muted); }
.login-hint {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.login-lang {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #1e40af; color: #fff; }
.btn-secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--brand-soft); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-wa { background: var(--wa); color: #fff; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 600;
}
.lang-toggle button {
  border: none;
  background: transparent;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.lang-toggle button.active {
  background: var(--brand);
  color: #fff;
}

/* —— App shell —— */
.agent-shell { min-height: 100vh; }

.agent-sidebar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  flex-direction: column;
  z-index: 40;
}

.sidebar-logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  padding: 8px 12px 20px;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-logo:hover { text-decoration: none; color: var(--brand); }

.sidebar-nav {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: var(--brand-soft);
  color: var(--brand);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}

.agent-main {
  padding: 16px 16px calc(var(--bottom-h) + 24px);
  max-width: 960px;
  margin: 0 auto;
}

/* Bottom nav — mobile */
.agent-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-h);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 40;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.agent-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 2px;
  min-width: 0;
}
.agent-bottom-nav a span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.agent-bottom-nav a svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}
.agent-bottom-nav a.active { color: var(--brand); }
.agent-bottom-nav a:hover { text-decoration: none; color: var(--brand); }

/* —— Cards / summary —— */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.summary-card .label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.summary-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}
.summary-card.accent .value { color: var(--accent); }
.summary-card.brand .value { color: var(--brand); }
.summary-card.warn .value { color: var(--warn); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.quick-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  text-decoration: none;
  color: var(--brand);
}
.quick-link svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
  fill: none;
  flex-shrink: 0;
}

/* —— Filters —— */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-bar input { flex: 1 1 160px; min-width: 0; }
.filter-bar select { flex: 0 1 140px; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.tab:hover:not(.active) { background: var(--brand-soft); color: var(--brand); }

/* —— Lists —— */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s;
}
.list-item:hover {
  border-color: var(--brand);
  text-decoration: none;
}
.list-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.list-item h3 {
  font-size: 0.95rem;
  font-weight: 650;
  margin-bottom: 4px;
}
.list-meta {
  font-size: 0.8rem;
  color: var(--muted);
}
.list-meta span + span::before {
  content: " · ";
  color: var(--line);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-in-progress { background: var(--brand-soft); color: var(--brand); }
.badge-closed { background: var(--ok-soft); color: var(--ok); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-expiring { background: var(--warn-soft); color: var(--warn); }
.badge-overdue, .badge-pending-doc { background: var(--danger-soft); color: var(--danger); }
.badge-high { background: var(--danger-soft); color: var(--danger); }
.badge-medium { background: var(--warn-soft); color: var(--warn); }
.badge-low { background: var(--accent-soft); color: var(--accent); }

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.error {
  text-align: center;
  padding: 32px 16px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  margin: -8px 0 12px;
}

/* —— Documents grid —— */
.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.doc-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.doc-card:hover {
  border-color: var(--brand);
  text-decoration: none;
}
.doc-thumb {
  height: 88px;
  background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.85rem;
}
.doc-thumb svg {
  width: 36px;
  height: 36px;
  stroke: var(--accent);
  fill: none;
  opacity: 0.85;
}
.doc-body { padding: 10px 12px 12px; }
.doc-body h3 { font-size: 0.9rem; margin-bottom: 4px; }
.doc-body .list-meta { font-size: 0.75rem; }

/* —— Detail panels —— */
.detail-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.detail-card h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}
.detail-card h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--ink);
}
.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 0.9rem;
}
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { font-weight: 550; word-break: break-word; }

.timeline {
  list-style: none;
  border-left: 2px solid var(--line);
  margin-left: 8px;
  padding-left: 16px;
}
.timeline li {
  position: relative;
  padding-bottom: 14px;
  font-size: 0.85rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}
.timeline .t-date { color: var(--muted); font-size: 0.75rem; }
.timeline .t-label { font-weight: 600; }

.notes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notes-list li {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.notes-list .n-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
  text-decoration: none;
}
.back-link:hover { color: var(--brand); }

/* Settings */
.agent-form .field { margin-bottom: 14px; }
.agent-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.agent-form textarea {
  min-height: 72px;
  resize: vertical;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.9rem;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* Modal (optional) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 28px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h2 { font-size: 1.1rem; }

@media (min-width: 768px) {
  .agent-sidebar { display: flex; }
  .agent-bottom-nav { display: none; }
  .agent-main {
    margin-left: var(--sidebar-w);
    padding: 24px 28px 40px;
    max-width: none;
  }
  .agent-topbar {
    margin-left: var(--sidebar-w);
    padding: 0 28px;
  }
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .quick-links {
    grid-template-columns: repeat(4, 1fr);
  }
  .doc-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }
  .modal {
    border-radius: var(--radius);
    max-height: 80vh;
  }
}

@media (min-width: 1100px) {
  .doc-grid { grid-template-columns: repeat(4, 1fr); }
}
