:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #111827;
  --text-muted: #6b7280;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header a.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header a.brand::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--primary);
  display: inline-block;
}

/* ---------- Shell / container ---------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}
@media (min-width: 900px) {
  .app-shell { max-width: 1080px; padding: 32px; }
}

h1 { font-size: 1.4rem; margin: 8px 0 4px; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; }
@media (min-width: 900px) { h1 { font-size: 1.8rem; } }

/* ---------- Layout helpers ---------- */
.page-grid { display: block; }
@media (min-width: 900px) {
  .page-grid.with-sidebar {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 28px;
    align-items: start;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* ---------- Forms ---------- */
label { display: block; font-size: 0.82rem; font-weight: 600; margin: 12px 0 5px; color: var(--text-muted); }
input[type="text"], input[type="tel"], input[type="email"], input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
input:focus { outline: none; border-color: var(--primary); }

.form-grid { display: block; }
@media (min-width: 700px) {
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .form-grid .full-width { grid-column: 1 / -1; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  text-align: center;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  margin-top: 12px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
@media (min-width: 900px) { .btn-primary { width: auto; } }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-secondary:hover { background: #dbeafe; }
.btn-small { padding: 6px 12px; font-size: 0.8rem; margin-top: 0; }
.btn-row { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.btn-row .btn { margin-top: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 4px; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.85rem;
  white-space: nowrap;
}
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th {
  background: #f8f9fb;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-light); }
.table-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.table-link:hover { text-decoration: underline; }

/* ---------- Misc ---------- */
.empty { color: var(--text-muted); text-align: center; padding: 28px 0; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--primary); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.subhead { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 16px; }

.preview-img { max-width: 220px; border-radius: var(--radius-sm); margin-top: 8px; display: block; }
.voice-controls { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin: 6px 0 2px; }
.hidden { display: none !important; }
.pending-tag { font-size: 0.68rem; background: var(--warn-bg); color: var(--warn-text); padding: 2px 6px; border-radius: 6px; margin-left: 6px; }

.sync-banner { position: fixed; top: 0; left: 0; right: 0; padding: 10px; text-align: center; font-size: 0.85rem; z-index: 100; }
.sync-ok { background: var(--success-bg); color: var(--success-text); }
.sync-error { background: var(--error-bg); color: var(--error-text); }

audio { max-width: 100%; }
