:root {
  --azure-blue: #0078d4;
  --azure-dark: #004578;
  --azure-light: #deecf9;
  --success-green: #107c10;
  --bg: #f3f2f1;
  --card-bg: #ffffff;
  --text: #323130;
  --text-muted: #605e5c;
  --border: #edebe9;
  --vote-active: #0078d4;
  --vote-hover: #106ebe;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background: var(--azure-dark);
  color: white;
  padding: 16px 0;
  margin-bottom: 24px;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
}

header .meta {
  font-size: 13px;
  opacity: 0.85;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.filter-bar input { flex: 1; min-width: 200px; }

.filter-bar .vote-count {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Item cards */
.item-list { display: flex; flex-direction: column; gap: 8px; }

.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.15s;
}

.item-card:hover { border-color: var(--azure-blue); }

.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  min-width: 56px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.vote-btn:hover {
  border-color: var(--vote-hover);
  color: var(--vote-hover);
}

.vote-btn.voted {
  border-color: var(--vote-active);
  background: var(--azure-light);
  color: var(--vote-active);
}

.vote-btn .arrow { font-size: 18px; line-height: 1; }

.item-content { flex: 1; min-width: 0; }

.item-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.item-title a {
  color: var(--text);
  text-decoration: none;
}

.item-title a:hover { color: var(--azure-blue); text-decoration: underline; }

.item-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.item-meta .tag {
  background: var(--azure-light);
  color: var(--azure-dark);
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
}

/* Loading / empty states */
.state-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 16px;
}

.state-msg .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--azure-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Admin styles */
.admin-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-controls label {
  font-weight: 600;
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--azure-blue);
  color: white;
}

.btn-primary:hover { background: var(--azure-dark); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg); }

/* Results table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.results-table th,
.results-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.results-table th {
  background: var(--azure-dark);
  color: white;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.results-table tr:hover td { background: var(--azure-light); }

.results-table .num {
  text-align: center;
  font-weight: 600;
}

.results-table .num.has-votes { color: var(--azure-blue); }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  margin-bottom: 24px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s;
}

.upload-area:hover { border-color: var(--azure-blue); }

.upload-area.dragging {
  border-color: var(--azure-blue);
  background: var(--azure-light);
}

.upload-area input[type="file"] { display: none; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 6px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success-green); }
.toast.error { background: #d13438; }

/* Responsive */
@media (max-width: 640px) {
  .item-card { flex-direction: column; }
  .vote-btn { flex-direction: row; min-width: auto; padding: 6px 14px; }
  .filter-bar { flex-direction: column; }
}
