/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --surface-hover: #eeeff1;
  --border: #e0e0e4;
  --text: #1a1a1a;
  --text-muted: #6b6b76;
  --accent: #1a1a1a;
  --accent-hover: #333;
  --danger: #d32f2f;
  --success: #2e7d32;
  --radius: 6px;
  --font: 'Lato', Helvetica, Arial, Lucida, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-brand img {
  height: 60px;
  width: auto;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  letter-spacing: 0.05em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.9375rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

button:hover, .btn:hover {
  background: var(--accent-hover);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-brand img {
  height: 32px;
  width: auto;
}

.topbar-brand span {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.875rem;
  letter-spacing: normal;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-user {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Portal */
.portal-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.portal-main h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.empty-state {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 3rem;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.file-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.file-name {
  font-weight: 500;
}

.file-size {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-family: var(--mono);
}

/* Admin */
.admin-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card h2 {
  font-size: 1.125rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.inactive-row {
  opacity: 0.5;
}

code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  background: #f0f0f3;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-active {
  background: #e8f5e9;
  color: var(--success);
}

.badge-inactive {
  background: #fef2f2;
  color: var(--danger);
}

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

.inline-form {
  display: inline;
}

.password-change summary {
  list-style: none;
  cursor: pointer;
}

.password-change summary::-webkit-details-marker {
  display: none;
}

.password-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.password-form input {
  width: 160px;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
}

.password-change {
  position: relative;
}

/* Add client form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.add-client-form button {
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .topbar { padding: 0.75rem 1rem; }
  .admin-main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .actions { flex-direction: column; align-items: flex-start; }
}
