:root {
  --bg: #f4efe8;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --line: rgba(115, 86, 60, 0.14);
  --text: #2f241d;
  --muted: #756355;
  --accent: #0f8b8d;
  --accent-strong: #0a6c6d;
  --danger: #c14953;
  --warning: #d98e04;
  --shadow: 0 22px 40px rgba(74, 48, 28, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 139, 141, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(217, 142, 4, 0.18), transparent 24%),
    linear-gradient(135deg, #f6f2eb 0%, #efe5d8 100%);
}

.app-shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.sidebar {
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 248, 241, 0.74);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.content { padding: 20px; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--accent); font-size: 12px; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
.muted { color: var(--muted); }
.menu { display: grid; gap: 10px; }
.menu-icon {
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
.menu-logout {
  margin-top: auto;
}
.menu-btn, .ghost-btn, .primary-btn {
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.menu-btn { background: transparent; text-align: left; border: 1px solid var(--line); display: flex; align-items: center; }
.menu-btn.active, .menu-btn:hover { background: var(--surface); box-shadow: var(--shadow); transform: translateY(-1px); }
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #fff; box-shadow: 0 14px 28px rgba(15, 139, 141, 0.3); }
.ghost-btn { background: rgba(255,255,255,0.7); border: 1px solid var(--line); }
.hero-card, .panel, .user-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.hero-card, .panel, .user-card { padding: 22px; }
.stats-grid, .panel-grid { display: grid; gap: 18px; margin-top: 20px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card { padding: 20px; border-radius: 22px; background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.62)); border: 1px solid var(--line); }
.stat-card strong { display: block; font-size: 34px; margin-top: 10px; }
.tab { display: none; }
.tab.active { display: block; }
.split-header, .panel-head, .filters, .form-actions { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.filters { flex-wrap: wrap; justify-content: flex-start; }
.account-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.3fr) repeat(4, minmax(170px, 1fr)) minmax(170px, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.account-form-panel,
.account-list-panel {
  margin-top: 18px;
}
.collapse-btn {
  min-width: 96px;
}
.collapsed {
  display: none;
}
#account-form-body {
  margin-top: 14px;
}
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  font: inherit;
}
.input-with-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.input-with-toggle input {
  width: 100%;
}
.eye-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 12px;
}
.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label, .mini-form { display: grid; gap: 8px; }
.mini-form { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.full { grid-column: 1 / -1; }
.inline-toggle { display: flex !important; align-items: center; gap: 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 14px; }
.inline-toggle input { width: auto; }
.table-wrap {
  background: transparent;
}
.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  table-layout: fixed;
}
.table-wrap thead th {
  background: transparent;
  padding: 0 12px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: #5f544a;
  letter-spacing: 0.02em;
}
.table-wrap tbody td {
  padding: 18px 12px;
  border: 0;
  vertical-align: middle;
  text-align: left;
  font-size: 14px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.92);
}
.table-wrap th:first-child,
.table-wrap td:first-child {
  width: 32%;
}
.table-wrap th:last-child,
.table-wrap td:last-child {
  width: 124px;
  text-align: right;
}
.table-wrap tbody td:first-child {
  border-radius: 14px 0 0 14px;
}
.table-wrap tbody td:last-child {
  border-radius: 0 14px 14px 0;
}
.sort-btn {
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.sort-btn:hover {
  color: var(--accent-strong);
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  min-width: 84px;
}
.badge.active { background: rgba(15, 139, 141, 0.14); color: var(--accent-strong); }
.badge.expiring_soon { background: rgba(217, 142, 4, 0.14); color: #9e6700; }
.badge.expired { background: rgba(193, 73, 83, 0.14); color: var(--danger); }
.badge.inactive { background: rgba(117, 99, 85, 0.14); color: var(--muted); }
.badge.deleted { background: rgba(193, 73, 83, 0.2); color: #8f1f30; }
.row-warning {
  box-shadow: none;
}
.row-warning td {
  background: rgba(255, 244, 244, 0.96);
}
.warn-text {
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  margin-top: 6px;
}
.account-col {
  padding-right: 20px;
}
.account-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.account-name-alert {
  color: #c14953;
}
.account-name-overdue {
  color: #7c3aed;
}
.account-name-warning {
  color: #b7791f;
}
.account-name-deleted {
  color: #8b8b95;
}
.account-subtitle {
  color: var(--muted);
  margin-top: 4px;
  word-break: break-word;
  font-size: 12px;
}
.compact-col,
.provider-col,
.date-col,
.status-col {
  font-size: 13px;
  color: #4c433b;
}
.date-col,
.status-col {
  white-space: nowrap;
}
.provider-col {
  word-break: break-word;
}
.list { display: grid; gap: 12px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.82);
}
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap .item-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  align-items: center;
}
.action-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(115, 86, 60, 0.1);
  border-radius: 12px;
  background: #f7f4ef;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #5b5148;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(74, 48, 28, 0.08);
  background: #ffffff;
}
.action-btn.danger {
  background: rgba(193, 73, 83, 0.08);
  color: var(--danger);
}
.small-btn {
  border: none;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f0ebe4;
  cursor: pointer;
}
.small-btn.danger { background: rgba(193, 73, 83, 0.12); color: var(--danger); }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #2f241d;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  font-size: 14px;
}
.page-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.page-btn.active {
  background: var(--accent);
  color: #fff;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}
.modal-overlay.show {
  display: flex;
}
.modal-card {
  width: min(760px, 100%);
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
}
.detail-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
.detail-item strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

@media (max-width: 1100px) {
  .app-shell, .panel-grid, .stats-grid, .mini-form, .form-grid, .account-filters { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}
