:root {
  --bg: #f8f9fa;
  --ink: #1a1a2e;
  --muted: #6c757d;
  --card: #ffffff;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --border: #e9ecef;
  --field-bg: #ffffff;
  --field-border: #dee2e6;
  --field-text: #1a1a2e;
  --field-placeholder: #adb5bd;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
  --sidebar-bg: #ffffff;
  --sidebar-border: #e9ecef;
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --card: #1e1e2e;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --border: #2e2e42;
  --field-bg: #161622;
  --field-border: #3e3e52;
  --field-text: #f1f5f9;
  --field-placeholder: #64748b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.3);
  --sidebar-bg: #1a1a28;
  --sidebar-border: #2e2e42;
}

[data-theme="ocean"] {
  --bg: #0a1628;
  --ink: #e0f0ff;
  --muted: #7ea8c9;
  --card: #0f2140;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --border: #1e3a5f;
  --field-bg: #0c1a30;
  --field-border: #1e3a5f;
  --field-text: #e0f0ff;
  --field-placeholder: #5a8aab;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --sidebar-bg: #0d1d35;
  --sidebar-border: #1e3a5f;
}

[data-theme="forest"] {
  --bg: #0d1a0f;
  --ink: #e5f2e7;
  --muted: #8aab8e;
  --card: #142318;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --border: #264a2d;
  --field-bg: #0b1610;
  --field-border: #264a2d;
  --field-text: #e5f2e7;
  --field-placeholder: #6a8a6e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --sidebar-bg: #101f14;
  --sidebar-border: #264a2d;
}

[data-theme="sunset"] {
  --bg: #fef7ee;
  --ink: #2d1f14;
  --muted: #8a6d55;
  --card: #ffffff;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --border: #f0d9c4;
  --field-bg: #ffffff;
  --field-border: #e0c4a8;
  --field-text: #2d1f14;
  --field-placeholder: #a08060;
  --shadow: 0 1px 3px rgba(180, 100, 50, 0.08), 0 4px 12px rgba(180, 100, 50, 0.05);
  --shadow-lg: 0 4px 20px rgba(180, 100, 50, 0.1);
  --sidebar-bg: #fffbf5;
  --sidebar-border: #f0d9c4;
}

[data-theme="rose"] {
  --bg: #1a0f18;
  --ink: #f5e6f0;
  --muted: #b08da6;
  --card: #241a22;
  --accent: #ec4899;
  --accent-hover: #db2777;
  --border: #3d2a3a;
  --field-bg: #1a1018;
  --field-border: #3d2a3a;
  --field-text: #f5e6f0;
  --field-placeholder: #8a6a80;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --sidebar-bg: #1f141d;
  --sidebar-border: #3d2a3a;
}

[data-theme="midnight"] {
  --bg: #09090b;
  --ink: #fafafa;
  --muted: #a1a1aa;
  --card: #18181b;
  --accent: #a78bfa;
  --accent-hover: #8b5cf6;
  --border: #27272a;
  --field-bg: #0f0f12;
  --field-border: #27272a;
  --field-text: #fafafa;
  --field-placeholder: #71717a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.5);
  --sidebar-bg: #111113;
  --sidebar-border: #27272a;
}

[data-theme="nord"] {
  --bg: #2e3440;
  --ink: #eceff4;
  --muted: #d8dee9;
  --card: #3b4252;
  --accent: #88c0d0;
  --accent-hover: #6eb5c4;
  --border: #4c566a;
  --field-bg: #2e3440;
  --field-border: #4c566a;
  --field-text: #eceff4;
  --field-placeholder: #8a92a0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.3);
  --sidebar-bg: #333a47;
  --sidebar-border: #4c566a;
}

[data-theme="lavender"] {
  --bg: #1e1b2e;
  --ink: #e8e0f0;
  --muted: #b8a9c9;
  --card: #2a2640;
  --accent: #c4b5fd;
  --accent-hover: #a78bfa;
  --border: #3d3654;
  --field-bg: #1e1b2e;
  --field-border: #3d3654;
  --field-text: #e8e0f0;
  --field-placeholder: #7a6d8a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #252238;
  --sidebar-border: #3d3654;
}

[data-theme="sage"] {
  --bg: #1a2421;
  --ink: #e5ebe8;
  --muted: #9bab9f;
  --card: #24302a;
  --accent: #7cb89a;
  --accent-hover: #5fa882;
  --border: #2f4038;
  --field-bg: #1a2421;
  --field-border: #2f4038;
  --field-text: #e5ebe8;
  --field-placeholder: #6a7d6e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #1f2a26;
  --sidebar-border: #2f4038;
}

[data-theme="amethyst"] {
  --bg: #1a1625;
  --ink: #ede9f2;
  --muted: #a89bb8;
  --card: #252033;
  --accent: #b794f6;
  --accent-hover: #9f7aea;
  --border: #3d3552;
  --field-bg: #1a1625;
  --field-border: #3d3552;
  --field-text: #ede9f2;
  --field-placeholder: #7a6d95;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #211d30;
  --sidebar-border: #3d3552;
}

[data-theme="sand"] {
  --bg: #f5f0e8;
  --ink: #2c2825;
  --muted: #6b635b;
  --card: #ffffff;
  --accent: #c17f59;
  --accent-hover: #b06d47;
  --border: #e5ddd2;
  --field-bg: #ffffff;
  --field-border: #e5ddd2;
  --field-text: #2c2825;
  --field-placeholder: #8a8278;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
  --sidebar-bg: #faf7f2;
  --sidebar-border: #e5ddd2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

/* ==================== Content Card Styles ==================== */

.content-card {
  margin-bottom: 24px;
}

.content-card .card-header {
  justify-content: space-between;
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header-left svg {
  color: var(--accent);
}

.items-list {
  display: flex;
  flex-direction: column;
}

.items-list:not(:empty)+.empty-state {
  display: none;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
  font-size: 14px;
}

.help-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: color-mix(in oklab, var(--accent) 8%, transparent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.help-tip svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent);
}

.help-tip strong {
  color: var(--ink);
  font-weight: 600;
}

.page-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.page-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ==================== Login Styles ==================== */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg) 0%, color-mix(in oklab, var(--bg) 90%, var(--accent) 10%) 100%);
}

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

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: white;
}

.login-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==================== Admin Layout ==================== */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: color-mix(in oklab, var(--accent) 10%, transparent);
  color: var(--ink);
}

.nav-item.active {
  background: color-mix(in oklab, var(--accent) 15%, transparent);
  color: var(--accent);
}

.nav-item.active svg {
  color: var(--accent);
}

.nav-item.logout:hover {
  background: color-mix(in oklab, #ef4444 10%, transparent);
  color: #ef4444;
}

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
  max-width: 1200px;
}

.admin-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.admin-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

.admin-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 10px;
  height: 38px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.settings-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-tab.is-active {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 14%, var(--card));
  color: var(--accent);
}

.settings-panel {
  display: none;
}

.settings-panel.is-active {
  display: block;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--card) 95%, var(--bg) 5%);
}

.card-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

#googleCredentialsForm {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Full width card spans both columns */
.card.full-width {
  grid-column: 1 / -1;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  align-items: end;
}

.form-row .form-group {
  min-width: 0;
}

.label {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--field-border);
  font-size: 14px;
  font-family: inherit;
  background: var(--field-bg);
  color: var(--field-text);
  -webkit-text-fill-color: currentColor;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}

.input-small {
  width: 80px;
}

select option {
  background: var(--field-bg);
  color: var(--field-text);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
  cursor: pointer;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

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

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 42px;
  line-height: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button:visited {
  color: var(--ink);
}

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

.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button.primary:visited {
  color: #fff;
}

.button.ghost {
  background: transparent;
}

.button.full-width {
  width: 100%;
}

.credentials-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Save Bar */
.save-bar {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* Theme Picker */
.admin-theme-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.admin-theme-btn:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}

.admin-theme-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

/* Notice */
.notice {
  padding: 12px 16px;
  border-radius: 10px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-size: 14px;
}

[data-theme="dark"] .notice,
[data-theme="ocean"] .notice,
[data-theme="forest"] .notice,
[data-theme="rose"] .notice,
[data-theme="midnight"] .notice {
  background: color-mix(in oklab, var(--card) 85%, var(--accent) 15%);
  border-color: var(--border);
  color: var(--ink);
}

/* Status message */
#status:not(:empty) {
  padding: 10px 16px;
  border-radius: 10px;
  background: color-mix(in oklab, #10b981 15%, transparent);
  border: 1px solid #10b981;
  color: #10b981;
  font-size: 14px;
  font-weight: 500;
}

.oauth-status {
  display: none;
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: color-mix(in oklab, var(--card) 85%, var(--bg) 15%);
  font-size: 14px;
}

.oauth-status:not(:empty) {
  display: block;
}

.oauth-status.is-success {
  border-color: #10b981;
  color: #0d7f5b;
  background: color-mix(in oklab, #10b981 10%, transparent);
}

.oauth-status.is-error {
  border-color: #ef4444;
  color: #b91c1c;
  background: color-mix(in oklab, #ef4444 12%, transparent);
}

[data-theme="dark"] .oauth-status.is-success,
[data-theme="ocean"] .oauth-status.is-success,
[data-theme="forest"] .oauth-status.is-success,
[data-theme="rose"] .oauth-status.is-success,
[data-theme="midnight"] .oauth-status.is-success {
  color: #6ee7b7;
}

[data-theme="dark"] .oauth-status.is-error,
[data-theme="ocean"] .oauth-status.is-error,
[data-theme="forest"] .oauth-status.is-error,
[data-theme="rose"] .oauth-status.is-error,
[data-theme="midnight"] .oauth-status.is-error {
  color: #fca5a5;
}

.calendar-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.calendar-list:empty::before {
  content: "No calendars loaded yet.";
  display: block;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 2px;
}

.calendar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: color-mix(in oklab, var(--card) 92%, var(--bg) 8%);
}

.calendar-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.calendar-item-main {
  min-width: 0;
}

.calendar-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-title {
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}

.calendar-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.calendar-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* Row styles for links_widgets.php */
.row {
  display: grid;
  grid-template-columns: 36px 1fr 1.3fr 2fr 130px 200px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.link-icon-cell {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-icon-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
}

.link-icon-symbol-preview {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  background: color-mix(in oklab, var(--card) 72%, var(--accent) 28%);
  border: 1px solid var(--border);
}

.row:last-child {
  border-bottom: none;
}

.row input,
.row select {
  margin: 0;
}

.link-icon-tools {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(220px, 1.5fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.link-icon-tools input,
.link-icon-tools select {
  min-width: 0;
}

.link-icon-tools-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-icon-auto {
  height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.link-icon-clear {
  height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

.row-actions .button {
  min-width: 54px;
  height: 36px;
  padding: 0 12px;
}

.widget-row {
  display: grid;
  grid-template-columns: 1.1fr 2fr 110px 130px 200px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.widget-row:last-child {
  border-bottom: none;
}

.widget-row textarea {
  min-height: 60px;
}

.inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline input[type="number"] {
  width: 68px;
  min-width: 68px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* Legacy support */
.wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 22px 64px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.header h1 {
  margin: 0;
  font-size: 26px;
}

.badge {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

/* Theme Picker (fixed to bottom of page) */
.theme-picker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  user-select: none;
}

.theme-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.theme-swatches {
  display: flex;
  gap: 4px;
}

.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--card);
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  line-height: 1;
}

.theme-swatch:hover {
  transform: scale(1.15);
  border-color: var(--muted);
}

.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
  transform: scale(1.1);
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }

  .admin-main {
    margin-left: 200px;
    padding: 24px 20px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .save-bar {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .sidebar {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-main {
    margin-left: 0;
    padding: 20px 16px;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
    gap: 8px;
  }

  .sidebar-footer {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .row,
  .widget-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .link-icon-tools {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .link-icon-tools-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .link-icon-auto {
    width: 100%;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .settings-tabs {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .settings-tab {
    flex: 0 0 auto;
  }

  .credentials-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .calendar-list {
    grid-template-columns: 1fr;
  }
}

/* Dark theme input fixes */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="ocean"] input[type="text"],
[data-theme="ocean"] input[type="password"],
[data-theme="ocean"] input[type="url"],
[data-theme="ocean"] input[type="number"],
[data-theme="ocean"] textarea,
[data-theme="ocean"] select,
[data-theme="forest"] input[type="text"],
[data-theme="forest"] input[type="password"],
[data-theme="forest"] input[type="url"],
[data-theme="forest"] input[type="number"],
[data-theme="forest"] textarea,
[data-theme="forest"] select,
[data-theme="rose"] input[type="text"],
[data-theme="rose"] input[type="password"],
[data-theme="rose"] input[type="url"],
[data-theme="rose"] input[type="number"],
[data-theme="rose"] textarea,
[data-theme="rose"] select,
[data-theme="midnight"] input[type="text"],
[data-theme="midnight"] input[type="password"],
[data-theme="midnight"] input[type="url"],
[data-theme="midnight"] input[type="number"],
[data-theme="midnight"] textarea,
[data-theme="midnight"] select {
  background: var(--field-bg);
  color: var(--field-text);
  border-color: var(--field-border);
  color-scheme: dark;
}

[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] select:-webkit-autofill,
[data-theme="ocean"] input:-webkit-autofill,
[data-theme="ocean"] input:-webkit-autofill:hover,
[data-theme="ocean"] input:-webkit-autofill:focus,
[data-theme="ocean"] textarea:-webkit-autofill,
[data-theme="ocean"] select:-webkit-autofill,
[data-theme="forest"] input:-webkit-autofill,
[data-theme="forest"] input:-webkit-autofill:hover,
[data-theme="forest"] input:-webkit-autofill:focus,
[data-theme="forest"] textarea:-webkit-autofill,
[data-theme="forest"] select:-webkit-autofill,
[data-theme="rose"] input:-webkit-autofill,
[data-theme="rose"] input:-webkit-autofill:hover,
[data-theme="rose"] input:-webkit-autofill:focus,
[data-theme="rose"] textarea:-webkit-autofill,
[data-theme="rose"] select:-webkit-autofill,
[data-theme="midnight"] input:-webkit-autofill,
[data-theme="midnight"] input:-webkit-autofill:hover,
[data-theme="midnight"] input:-webkit-autofill:focus,
[data-theme="midnight"] textarea:-webkit-autofill,
[data-theme="midnight"] select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset;
  -webkit-text-fill-color: var(--field-text);
  caret-color: var(--field-text);
}

[data-theme="sunset"] .notice {
  background: #fff0e0;
  border-color: #f0d0a8;
  color: #8a4a20;
}
