:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --primary: #1f3a5f;
  --sidebar: #111827;
  --primary-soft: #e9eef7;
  --text: #1a1f2b;
  --border: #d9dfeb;
  --danger: #b42318;
  --success: #157347;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family, "Segoe UI", "Helvetica Neue", Arial, sans-serif);
  color: var(--text);
  background: linear-gradient(160deg, #eff3f8 0%, #dfe7f2 100%);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(23, 32, 58, 0.1);
}

.login-box h1 { margin-top: 0; }
label { display: block; margin: 14px 0 6px; font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
input, textarea, select, button {
  font-family: inherit;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, #6b7280 50%),
    linear-gradient(135deg, #6b7280 50%, transparent 50%),
    linear-gradient(to right, #e5e7eb, #e5e7eb);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    calc(100% - 34px) 50%;
  background-size: 6px 6px, 6px 6px, 1px 18px;
  background-repeat: no-repeat;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--focus-ring, var(--primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring, var(--primary)) 20%, transparent);
}
input[readonly] {
  background: #f8fafc;
  color: #4b5563;
}
.color-input {
  height: 44px;
  padding: 4px;
}
.color-input + small {
  display: block;
  margin-top: 6px;
  color: #4b5563;
  font-size: 12px;
}
textarea { resize: vertical; }
button {
  margin-top: 18px;
  width: fit-content;
  min-width: 170px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 0;
  background: var(--button-bg, var(--primary));
  color: var(--button-text, #fff);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}
button:hover {
  filter: brightness(0.94);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--button-bg, var(--primary)) 30%, transparent);
}
button:active {
  transform: translateY(1px);
}

.form-grid button {
  justify-self: start;
  grid-column: 1 / -1;
}

.alert, .notice {
  margin: 12px 0;
  padding: 10px;
  border-radius: 8px;
}
.alert, .notice.err { background: #fdecec; color: var(--danger); }
.notice.ok { background: #e8f5ee; color: var(--success); }

.backend-page { min-height: 100vh; }
.wp-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text, #d7dcee);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.sidebar nav a {
  display: block;
  color: var(--sidebar-link, #d7dcee);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.sidebar nav a.active,
.sidebar nav a:hover { background: var(--sidebar-active, var(--primary)); color: #fff; }
.sidebar nav a.nav-bottom-link {
  margin-top: auto;
}

.content { padding: 24px; }
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.stack h3 { margin-top: 0; }
.form-grid {
  display: grid;
  gap: 12px;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.item-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: #fbfcfe; }
.inline-form button { min-width: 120px; }

@media (max-width: 900px) {
  .wp-shell { grid-template-columns: 1fr; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
}
