*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #1D9E75;
  --green-dark: #158a63;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --danger: #dc2626;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth layout */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Forms */
.field { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  width: 100%;
  padding: 0.625rem;
}

.btn-primary:hover { background: var(--green-dark); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover { background: var(--bg); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* Alert */
.alert {
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* App layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--green);
  padding: 0 0.5rem;
  margin-bottom: 1rem;
}

.sidebar a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9375rem;
  transition: background 0.15s;
}

.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: #e6f5f0; color: var(--green); font-weight: 500; }

.sidebar-footer { margin-top: auto; }

.main { flex: 1; padding: 2rem; overflow-y: auto; }

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

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

.card-label { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 0.375rem; }
.card-value { font-size: 1.75rem; font-weight: 700; color: var(--green); }

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

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 0.625rem 0.75rem; border-bottom: 2px solid var(--border); font-size: 0.8125rem; color: var(--text-muted); font-weight: 600; }
td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

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

.badge-green { background: #e6f5f0; color: var(--green); }
.badge-gray { background: #f3f4f6; color: var(--text-muted); }

/* Section */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

@media (max-width: 768px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0 0.25rem 0 0.75rem;
    gap: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    height: 52px;
    background: var(--surface);
  }

  .sidebar-brand {
    font-size: 1.375rem;
    font-weight: 800;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    flex: 1;
  }

  .sidebar a {
    flex-shrink: 0;
    margin: 0;
    padding: 0 0.625rem;
    font-size: 0.875rem;
    white-space: nowrap;
    border-radius: 0;
    height: 52px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
  }

  .sidebar a.active {
    border-bottom-color: var(--green);
    color: var(--green);
    background: transparent;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    padding: 0;
    margin: 0;
  }

  .sidebar-footer .btn {
    width: auto !important;
    height: 52px;
    padding: 0 0.625rem;
    font-size: 0;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-footer .btn::after {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }

  .main { padding: 1rem; }

  .cards { grid-template-columns: repeat(2, 1fr); }

  #save-btn { display: block; margin: 0 auto; }
}
