:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --tertiary: #999;
  --border: rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.22);
  --primary: #1d5fa5;
  --primary-bg: #e6f1fb;
  --primary-border: #b5d4f4;
  --success: #1d9e75;
  --success-bg: #e1f5ee;
  --danger: #a32d2d;
  --danger-bg: #fceaea;
  --warning: #ba7517;
  --warning-bg: #faeeda;
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

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

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
header h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 4px;
}
.header-left p { margin: 0; }
.header-right {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.admin-rules-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.admin-rules-button:hover {
  background: #174f8d;
  border-color: #174f8d;
}
.admin-rules-button:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}
.admin-rules-icon {
  font-size: 15px;
  line-height: 1;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 17px; margin: 0 0 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 12px;
}
.card h3 {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 10px;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 50px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}
.dropzone:hover { background: var(--bg); }
.dropzone.dragging {
  background: var(--primary-bg);
  border-color: var(--primary);
}
.dropzone.busy { cursor: wait; }
.dropzone p { margin: 0 0 4px; }
.dropzone em { color: var(--primary); font-style: normal; text-decoration: underline; }

/* File row */
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-row .file-info { flex: 1; }
.file-row .file-info p { margin: 0; }
.icon-ok {
  display: inline-block;
  width: 28px; height: 28px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  font-weight: 600;
}

/* Recognition */
.recognition {
  border-left: 3px solid var(--success);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.recognition-left .label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.recognition .adapter-name {
  font-size: 19px;
  font-weight: 500;
  margin: 0;
}
.recognition p { margin: 0; }

.adapter-override summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
}
.adapter-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.adapter-list button {
  text-align: left;
  padding: 6px 10px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.stat .label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 2px;
}
.stat .value {
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}

/* Cross-section table */
.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.cs-table th, .cs-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 0.5px solid var(--border);
}
.cs-table th {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cs-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cs-table tr:last-child td { border-bottom: none; }

/* Alerts */
.alert-error {
  border-left: 3px solid var(--danger);
  background: var(--danger-bg);
}
.alert-warning {
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
}
.alert-warning ul.issues {
  list-style: none;
  padding: 0;
  margin: 0;
}
.alert-warning ul.issues li {
  padding: 4px 0;
  font-size: 13px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  letter-spacing: 0.04em;
}
.badge-warning { background: var(--warning); color: white; }
.badge-error { background: var(--danger); color: white; }
.badge-info { background: var(--primary); color: white; }

/* Buttons */
button {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
}
button:hover { background: var(--bg); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 500;
  background: var(--primary-bg);
  color: var(--primary);
  border: 0.5px solid var(--primary-border);
  border-radius: var(--radius);
  margin-top: 10px;
}
.btn-primary:hover { background: #d6e9f8; }
.btn-primary:disabled { background: var(--bg); color: var(--muted); }

/* ===== Tundmatud materjalid (interaktiivne klassifitseerimine) ===== */
.unknown-materials {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.unknown-materials th,
.unknown-materials td {
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border);
  text-align: left;
}
.unknown-materials th {
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
}
.unknown-materials td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.unknown-materials code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.decision-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 4px;
  border: 0.5px solid var(--border);
  cursor: pointer;
}
.btn-sawable {
  background: #e1f5ee;
  color: #0f6e56;
  border-color: #1d9e75;
}
.btn-sawable:hover { background: #c8e9d9; }
.btn-not-sawable {
  background: #fde8e8;
  color: #aa3030;
  border-color: #c45252;
}
.btn-not-sawable:hover { background: #f5d2d2; }

.alert-info {
  background: #f0f7fb;
  border-left: 3px solid #4a8bb3;
}
