:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d0d4da;
  --text: #1c2126;
  --muted: #5a6472;
  --accent: #1f5f9e;
  --error: #a11c1c;
  --notice-bg: #fdf3d8;
  --notice-border: #e0c675;
  --ok-bg: #e4f1e4;
  --ok-border: #8fbc8f;
  --bad-bg: #f7dede;
}

* { box-sizing: border-box; }

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

h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }

/* Application shell */

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

.sidebar {
  flex: 0 0 13rem;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
}

.sidebar .brand {
  font-weight: 600;
  margin: 0 1rem 1rem;
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }

.sidebar a {
  display: block;
  padding: 0.4rem 1rem;
  color: var(--text);
  text-decoration: none;
}

.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--bg); font-weight: 600; }

.main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { margin: 0; }

.session { display: flex; align-items: center; gap: 0.5rem; }
.session form { margin: 0; }

.content { padding: 1.5rem; }

/* Login page */

.standalone {
  display: flex;
  justify-content: center;
  padding: 3rem 1rem;
}

.card {
  width: 100%;
  max-width: 26rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
}

/* Notices and flash messages */

.notice { color: var(--muted); }
.error { color: var(--error); font-weight: 600; }

.flash {
  padding: 0.5rem 0.75rem;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: 3px;
}

ul.error {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem 0.5rem 1.75rem;
  border: 1px solid var(--error);
  border-radius: 3px;
}

/* Record tables */

table.records {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
}

table.records th, table.records td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.records th { background: var(--bg); font-weight: 600; }
table.records tr:last-child td { border-bottom: 0; }

.row-actions { display: flex; align-items: baseline; gap: 0.75rem; }
.row-actions form { margin: 0; }

/* Service status */

dl.summary {
  display: grid;
  grid-template-columns: max-content auto;
  gap: 0.1rem 0.75rem;
  margin: 0 0 1rem;
}

dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; font-weight: 600; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.badge.active { background: var(--ok-bg); border-color: var(--ok-border); color: var(--text); }
.badge.failed { background: var(--bad-bg); border-color: var(--error); color: var(--error); }

/* Audio */

table.records audio { height: 2rem; vertical-align: middle; }

/* Forms */

.record-form { max-width: 32rem; }

.form-actions { display: flex; align-items: center; gap: 1rem; }

label { display: block; margin-top: 0.75rem; font-size: 0.9rem; }

input[type="text"], input[type="password"], input:not([type]), select, textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font: inherit;
  background: #fff;
  color: inherit;
}

textarea { resize: vertical; }

button {
  margin-top: 1rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:hover { background: #174a7c; }

button.link {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

button.link:hover { background: transparent; color: #174a7c; }

.session button {
  margin: 0;
  background: transparent;
  color: var(--accent);
}

.session button:hover { background: var(--bg); }

@media (max-width: 40rem) {
  .layout { flex-direction: column; }
  .sidebar { flex: 0 0 auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar ul { display: flex; flex-wrap: wrap; }
  .content { padding: 1rem; }
}
