:root {
  --bg: #f5f0eb;
  --surface: #ffffff;
  --border: #e2ddd8;
  --border-light: #ede9e3;
  --text: #3e3e3e;
  --text-secondary: #6b6560;
  --text-muted: #9e9890;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-sm: 4px;
  --online: #2d7d46;
  --danger: #c0392b;
}

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

body {
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

.logo {
  border-radius: 6px;
}

/* ── Nav ── */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  height: 52px;
  background: #76b1d3;
  color: #fff;
}

.top-nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: 0.9rem;
  transition: color 0.1s;
}
.top-nav a:hover {
  color: #fff;
}
.top-nav a.brand {
  font-weight: 700;
  margin-left: 0;
  letter-spacing: -0.02em;
  color: #fff;
  font-size: 1rem;
}

/* ── Layout ── */
.page-wrapper {
  display: flex;
  min-height: calc(100vh - 52px);
  background: var(--bg);
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* .sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--border-light);
} */

/* .sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #76b1d3;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
} */

/* .sidebar-username {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
} */

.sidebar-nav {
  /* padding: 0.6rem 0; */
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition:
    background 0.1s,
    color 0.1s;
}

.sidebar-link:hover {
  background: #faf8f5;
  color: var(--text);
}
.sidebar-link.active {
  background: #f3ede6;
  color: var(--text);
  border-left-color: #76b1d3;
  font-weight: 600;
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.1s;
}
.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
  opacity: 1;
}

.sidebar-support {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding: 1rem 1.25rem;
}

/* .sidebar-support .sidebar-support-links { */
/* margin-top: auto; */
/* } */

/* ── Main content ── */
main {
  max-width: 820px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}
main.with-sidebar {
  max-width: none;
  margin: 0;
  padding: 2.5rem 3rem;
  flex: 1;
  min-width: 0;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}
h2 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.75rem;
}
h3 {
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.75rem;
}

.page-subtitle {
  color: var(--text-secondary);
  margin: 0 0 2rem;
  font-size: 0.9rem;
}

/* ── Flash ── */
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fdf6e3;
  border: 1px solid #e8d5a3;
  border-left: 4px solid #d4a017;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.flash-dismiss {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin: 0;
  flex-shrink: 0;
  transition: color 0.1s;
}
.flash-dismiss:hover {
  color: var(--text);
}

.callout-warning {
  background: #fff7e8;
  border: 1px solid #e7cf97;
  border-left: 4px solid #d4a017;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.callout-warning p {
  margin: 0 0 0.5rem;
}

.callout-warning p:last-child {
  margin-bottom: 0;
}

/* ── Forms ── */
.form-page {
  max-width: 400px;
}

label {
  display: block;
  margin-bottom: 1.1rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

label input {
  display: block;
  width: 100%;
  padding: 0.55rem 0.8rem;
  margin-top: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

label input:focus {
  outline: 2px solid #76b1d3;
  outline-offset: 1px;
  border-color: transparent;
}

/* ── Buttons ── */
/* .btn, button[type=submit] { */
.btn {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: #76b1d3;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  /* margin-right: 0.5rem; */
  /* margin-top: 0.5rem; */
  transition: opacity 0.15s;
  letter-spacing: 0.01em;
}
/* .btn:hover, button[type=submit]:hover { opacity: 0.82; } */
.btn:hover {
  opacity: 0.82;
}
/* .btn:disabled, button[type=submit]:disabled { opacity: 0.4; cursor: not-allowed; } */
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--text-secondary);
}
.btn-small {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
}
.btn-danger {
  background: var(--danger);
}

/* ── Status dots ── */
.status {
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}
.status::before {
  content: "●";
  font-size: 0.65em;
}
.status.online {
  color: var(--online);
}
.status.offline {
  color: var(--text-muted);
}
.status.pending {
  color: #b57614;
}

/* ── Hero (landing page) ── */
.hero {
  text-align: center;
  padding: 5rem 1rem;
}
.hero h1 {
  font-size: 2.75rem;
  letter-spacing: -0.04em;
}
.hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin: 0.5rem 0 2rem;
}

/* ── Dashboard printer cards ── */
.printer-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.printer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.printer-card-pending {
  background: #fffaf1;
  border-color: #ead7ad;
}

.printer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.printer-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.printer-card-footer {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  padding-top: 0.25rem;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
  background: var(--bg);
}
.drop-zone:hover,
.drop-zone--active {
  border-color: #999;
  background: #ede8e1;
}
.drop-zone input[type="file"] {
  display: none;
}
.drop-zone-prompt {
  margin: 0 0 0.5rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}
.drop-zone-label {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: #76b1d3;
  color: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.15s;
}
.drop-zone-label:hover {
  opacity: 0.82;
}
.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}
.drop-zone-filename {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0.4rem 0 0;
  font-style: italic;
}

/* .quick-print-form button[type=submit] { width: 100%; margin-top: 0.75rem; display: block; text-align: center; } */
.quick-print-form .btn {
  width: 100%;
  margin-top: 0.75rem;
  display: block;
  text-align: center;
}

/* ── Printers list (management page) ── */
.printer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.printer-list li {
  padding: 0.9rem;
  border-bottom: 1px solid var(--border-light);
}
.printer-list li:last-child {
  border-bottom: none;
}

.printer-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  display: flex;
  justify-content: center;
}
.printer-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}
.printer-name:hover {
  text-decoration: underline;
}
.printer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.printer-db-table code {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.printer-db-table td,
.printer-db-table th {
  vertical-align: middle;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}
.inline-input {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  width: 140px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.inline-input:focus {
  outline: 2px solid #76b1d3;
  outline-offset: 1px;
  border-color: transparent;
}

/* ── Printer detail ── */
.printer-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.message-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.88rem;
}
.message-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.message-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.message-table tbody tr:hover td {
  background: #faf7f3;
}

code {
  background: #f0ebe5;
  padding: 0.15em 0.45em;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: ui-monospace, "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  color: var(--text);
  word-break: break-all;
}

/* ── Print keys list ── */
.print-key-list {
  list-style: none;
  padding: 0;
}
.print-key-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  flex-wrap: wrap;
}
.print-key-list li:last-child {
  border-bottom: none;
}

/* ── Settings ── */
section {
  margin-bottom: 2.5rem;
}
section h2 {
  margin-top: 0;
}

.danger-zone {
  border: 1px solid #f5c6c2;
  background: #fff9f9;
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
.danger-zone h2 {
  color: var(--danger);
}

/* ── Misc ── */
.form-link {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.form-link a {
  color: var(--text);
}

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

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
