/* ==========================================================
   Due Reminder — design system ("Clinical Teal" palette)
   ========================================================== */
:root {
  --primary: #0f7a6c;
  --primary-dark: #0b5d52;
  --primary-light: #14a390;
  --primary-pale: #e6f7f5;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --bg: #f3f7f6;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --info: #0f7a6c;
  --info-bg: #e6f7f5;
  --secondary-bg: #f1f5f9;

  --sidebar-width: 250px;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e6efed;
  --sidebar-text: #4b6360;
  --sidebar-text-muted: #93a8a5;
  --sidebar-hover-bg: #eef9f7;

  --header-height: 64px;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

a {
  color: var(--primary);
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex-shrink: 0;
  display: block;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.15;
  color: var(--primary-dark);
}

.sidebar-brand-text small {
  display: block;
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--sidebar-text-muted);
}

/* Sized to comfortably fit this app's small, fixed menu without its own
   scrollbar; overflow-y stays as a safety net only (kicks in solely if a
   future menu addition ever outgrows the available height). */
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.65rem 0.75rem 0.25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover-bg);
  color: var(--primary-dark);
}

.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav .nav-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-footer {
  padding: 0.7rem 1.1rem 0.85rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 0.72rem;
  color: var(--sidebar-text-muted);
}

.sidebar-logout-btn {
  border: none;
  background: var(--sidebar-hover-bg);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  width: 100%;
}

.sidebar-logout-btn:hover {
  background: #dcf3ef;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

/* ---------------- Top header ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.75rem;
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar-greeting {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.topbar-greeting span {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.82rem;
  display: block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-toggle-btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.75rem 2rem;
}

/* ---------------- Footer ----------------
   Sticky to the bottom of the viewport so it stays visible on long pages
   instead of only showing up once you scroll all the way down. */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  padding: 0.9rem 1.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.05);
}

.app-footer strong {
  color: var(--primary-dark);
}

/* ---------------- Page header ---------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  margin: 0;
  font-weight: 700;
  color: var(--text);
  font-size: 1.4rem;
}

.page-header p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.87rem;
}

/* ---------------- Cards ---------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-body {
  padding: 1.25rem;
}

.filter-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
}

.stat-card {
  position: relative;
  background: linear-gradient(180deg, var(--card-bg), var(--card-bg));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-pale);
  color: var(--primary);
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
}

.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

.stat-card.accent-danger::before { background: var(--danger); }
.stat-card.accent-warning::before { background: var(--warning); }
.stat-card.accent-info::before { background: var(--info); }
.stat-card.accent-success::before { background: var(--success); }
.stat-card.accent-muted::before { background: var(--muted); }

.stat-card.accent-danger .stat-card-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.accent-warning .stat-card-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.accent-info .stat-card-icon { background: var(--info-bg); color: var(--info); }
.stat-card.accent-success .stat-card-icon { background: var(--success-bg); color: var(--success); }
.stat-card.accent-muted .stat-card-icon { background: var(--secondary-bg); color: var(--muted); }

/* ---------------- Badges (pill style) ---------------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.pill-success { background: var(--success-bg); color: var(--success); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-secondary { background: var(--secondary-bg); color: var(--muted); }

/* ---------------- Tables ---------------- */
.table-modern {
  margin-bottom: 0;
}

.table-modern thead th {
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  padding: 0.75rem 0.85rem;
  background: #fafbfd;
}

.table-modern tbody td {
  padding: 0.7rem 0.85rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr.row-overdue {
  background: #fff7f7;
}

/* ---------------- Buttons / forms ---------------- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

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

.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--border);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 0.2rem rgba(15, 122, 108, 0.15);
}

/* ---------------- Auth / login split screen ---------------- */
.auth-split {
  min-height: 100vh;
  display: flex;
}

.auth-panel-left {
  flex: 1.1;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary) 60%, var(--primary-light));
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
}

.auth-panel-left .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
}

.auth-panel-left .brand-mark img {
  width: 100%;
  height: 100%;
}

.auth-panel-left h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.auth-panel-left p {
  color: #d5f2ec;
  max-width: 340px;
}

.auth-panel-right {
  flex: 1;
  background: #f8faf9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h3 {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.auth-card .subtitle {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .auth-panel-left { display: none; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 2px 0 16px rgba(0,0,0,0.15); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle-btn { display: inline-flex; }
  .main-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

/* ---------------- Misc ---------------- */
.section-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin: 1.25rem 0 0.6rem;
}

.doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.doc-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  background: #fafbfd;
}

.doc-list .doc-meta {
  font-size: 0.78rem;
  color: var(--muted);
}


/* ---------------- Pagination ---------------- */
.pagination .page-link {
  color: var(--primary-dark);
  border-color: var(--border);
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
}

.pagination .page-link:hover {
  background: var(--primary-pale);
  color: var(--primary-dark);
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.table-client-pagination {
  display: flex;
  justify-content: center;
}

/* ---------------- Inline contact-person rows (Customer Create) ---------------- */
.contact-row td {
  vertical-align: top;
}

.remove-contact-row {
  line-height: 1;
  padding: 0.25rem 0.55rem;
}
