:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5f6672;
  --border: #e1e4e9;
  --accent: #1565c0;
  --accent-text: #ffffff;
  --danger: #c62828;
  --success: #2e7d32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  line-height: 1.5;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 20px 16px;
  text-align: center;
}

header h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.party-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.party-row:last-child {
  border-bottom: none;
}

.badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.party-name {
  font-weight: 600;
}

.party-bloc {
  color: var(--muted);
  font-size: 13px;
}

.pie-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.pie {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--border);
}

.pie-hole {
  position: absolute;
  inset: 18%;
  background: var(--card);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pie-hole .pie-total {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.pie-hole .pie-total-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.party-menu-item {
  border-bottom: 1px solid var(--border);
}

.party-menu-item:last-child {
  border-bottom: none;
}

.party-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
}

.party-value-badge {
  margin-inline-start: auto;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  color: var(--muted);
}

.party-menu-item.expanded .party-value-badge {
  color: var(--text);
}

.slice-editor {
  display: none;
  padding: 2px 0 16px;
}

.party-menu-item.expanded .slice-editor {
  display: block;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.stepper input[type="range"] {
  flex: 1;
}

.total-bar {
  position: sticky;
  bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
  margin: 0 -16px;
}

.total-bar.ok {
  color: var(--success);
}

.total-bar.bad {
  color: var(--danger);
}

input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

button:disabled {
  background: #9aa5b1;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.message {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.message.error {
  background: #fdecea;
  color: var(--danger);
}

.message.success {
  background: #eaf6ea;
  color: var(--success);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.result-input {
  width: 56px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.locked {
  background: #fdecea;
  color: var(--danger);
}

.pill.open {
  background: #eaf6ea;
  color: var(--success);
}

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