:root {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --surface2:  #f5f5f7;
  --border:    #e5e5e5;
  --border2:   #d4d4d4;
  --ink:       #111111;
  --ink2:      #555555;
  --ink3:      #999999;
  --blue:      #2563eb;
  --blue-dark: #1d4ed8;
  --blue-bg:   #eff6ff;
  --blue-text: #1e40af;
  --green:     #16a34a;
  --green-bg:  #f0fdf4;
  --red:       #dc2626;
  --red-bg:    #fef2f2;
  --amber:     #d97706;
  --amber-bg:  #fffbeb;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0;
  position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 100; gap: 4px;
}

.sidebar-logo {
  width: 34px; height: 34px;
  background: var(--blue); border-radius: var(--radius);
  display: grid; place-items: center; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}
.sidebar-logo svg { width: 16px; height: 16px; }

.nav-item {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--ink3);
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover  { background: var(--surface2); color: var(--ink2); }
.nav-item.active { background: var(--blue-bg);  color: var(--blue); }
.nav-item.active::after {
  content: ''; position: absolute;
  left: -1px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--blue); border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 16px; height: 16px; }

.sidebar-bottom {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding-bottom: 4px;
}

.user-dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue-bg); border: 1.5px solid #bfdbfe;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--blue);
}

.logout-icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--ink3); cursor: pointer;
  transition: background .15s, color .15s;
}
.logout-icon-btn:hover { background: #fee2e2; color: var(--red); }
.logout-icon-btn svg { width: 15px; height: 15px; }

/* ── Main ── */
.main {
  margin-right: var(--sidebar-w);
  flex: 1; padding: 36px 40px;
}

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.5px; }
.page-sub   { font-size: 13px; color: var(--ink3); margin-top: 3px; }

/* ── Buttons ── */
.btn {
  height: 36px; padding: 0 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, box-shadow .15s, transform .1s;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--blue); color: #fff; border: none; box-shadow: 0 1px 3px rgba(37,99,235,0.3); }
.btn-primary:hover { background: var(--blue-dark); }

.btn-ghost { background: var(--surface); border: 1px solid var(--border2); color: var(--ink2); }
.btn-ghost:hover { background: var(--surface2); color: var(--ink); }

.btn-danger { background: var(--red-bg); border: 1px solid #fecaca; color: var(--red); }
.btn-danger:hover { background: #fee2e2; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
}
.badge-blue  { background: var(--blue-bg);  color: var(--blue-text); border: 1px solid #bfdbfe; }
.badge-green { background: var(--green-bg); color: var(--green);     border: 1px solid #bbf7d0; }
.badge-red   { background: var(--red-bg);   color: var(--red);       border: 1px solid #fecaca; }
.badge-gray  { background: var(--surface2); color: var(--ink2);      border: 1px solid var(--border); }

/* ── Form fields ── */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--ink2); margin-bottom: 6px; text-align: right;
}
.field input, .field select {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--ink);
  font-size: 14px; font-family: var(--font);
  outline: none; direction: ltr; text-align: right;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: var(--surface);
}
.field input::placeholder { color: var(--ink3); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: transform .3s cubic-bezier(.16,1,.3,1), opacity .3s;
  z-index: 9999; pointer-events: none; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #166534; }
.toast.error   { background: var(--red); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px; backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); width: 100%; max-width: 400px;
  animation: modalIn .2s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
@keyframes modalIn {
  from { opacity:0; transform:scale(0.96) translateY(8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:20px 20px 0; }
.modal-header h2 { font-size:16px; font-weight:700; color:var(--ink); }
.modal-close {
  width:26px; height:26px; border-radius:var(--radius-sm);
  background:var(--surface2); color:var(--ink2);
  display:grid; place-items:center; cursor:pointer; transition:background .15s;
}
.modal-close:hover { background:var(--border); color:var(--ink); }
.modal-close svg { width:13px; height:13px; }
.modal-body   { padding:18px 20px; }
.modal-footer { padding:0 20px 20px; display:flex; justify-content:flex-end; gap:8px; }

.modal-alert {
  border-radius:var(--radius); padding:9px 12px;
  font-size:12px; font-weight:500; margin-bottom:14px; display:none;
}
.modal-alert.error   { background:var(--red-bg);   border:1px solid #fecaca; color:var(--red);   display:block; }
.modal-alert.success { background:var(--green-bg); border:1px solid #bbf7d0; color:var(--green); display:block; }

@keyframes fadeUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
.fade-up { animation: fadeUp .3s cubic-bezier(.16,1,.3,1) both; }
