/* ============================================================
   TimePortal — Design System
   ============================================================ */

:root {
  --blue:        #1A6FE8;
  --blue-dark:   #1558C0;
  --blue-light:  #EEF4FD;
  --green:       #16A34A;
  --green-light: #DCFCE7;
  --orange:      #EA580C;
  --orange-light:#FFF7ED;
  --red:         #DC2626;
  --red-light:   #FEF2F2;
  --purple:      #7C3AED;
  --purple-light:#F5F3FF;
  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-300:    #CBD5E1;
  --gray-400:    #94A3B8;
  --gray-500:    #64748B;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1E293B;
  --gray-900:    #0F172A;
  --sidebar-w:   240px;
  --header-h:    64px;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
}

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

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 17px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: white;
  letter-spacing: -.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 14px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--gray-300);
  font-size: 13.5px;
  transition: all .15s;
  text-decoration: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; text-decoration: none; }
.nav-item.active { background: var(--blue); color: white; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--gray-400); }
.logout-btn { color: var(--gray-400); transition: color .15s; }
.logout-btn:hover { color: white; }

/* ── MAIN ───────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-title    { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-top: 3px; }
.page-actions  { display: flex; gap: 10px; flex-shrink: 0; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.card-body  { padding: 20px; }

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.green  { background: var(--green-light);  color: var(--green); }
.stat-icon.orange { background: var(--orange-light); color: var(--orange); }
.stat-icon.red    { background: var(--red-light);    color: var(--red); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ── TABLE ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table       { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  font-size: 13.5px;
}
tr:last-child td { border-bottom: none; }
tr:hover td      { background: var(--gray-50); }

.td-primary   { font-weight: 600; color: var(--gray-900); }
.td-secondary { font-size: 12px; color: var(--gray-400); }

/* ── BADGE ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-success  { background: var(--green-light);  color: var(--green); }
.badge-warning  { background: var(--orange-light); color: var(--orange); }
.badge-danger   { background: var(--red-light);    color: var(--red); }
.badge-dark     { background: var(--gray-200);     color: var(--gray-600); }
.badge-secondary{ background: var(--gray-100);     color: var(--gray-500); }
.badge-blue     { background: var(--blue-light);   color: var(--blue); }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn svg   { width: 16px; height: 16px; }

.btn-primary { background: var(--blue);    color: white; }
.btn-success { background: var(--green);   color: white; }
.btn-danger  { background: var(--red);     color: white; }
.btn-warning { background: var(--orange);  color: white; }
.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--blue); }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full   { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: .01em;
}
.form-label.required::after { content: " *"; color: var(--red); }

.form-control {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--gray-800);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,111,232,.12);
}
.form-control:disabled {
  background: var(--gray-50);
  color: var(--gray-400);
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11.5px; color: var(--gray-400); }

/* ── SEARCH BAR ─────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-input-wrap svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  width: 16px; height: 16px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: white;
  transition: border-color .15s;
}
.search-input:focus { outline: none; border-color: var(--blue); }

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  justify-content: flex-end;
}
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--gray-600);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.page-btn:hover { background: var(--gray-100); text-decoration: none; }
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.page-info { font-size: 12.5px; color: var(--gray-400); margin-right: 12px; }

/* ── TABS ───────────────────────────────────────────────────── */
.tabs        { display: flex; gap: 2px; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; }
.tab-item {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  text-decoration: none;
}
.tab-item:hover { color: var(--gray-800); text-decoration: none; }
.tab-item.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── ALERT ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--green-light);  color: #166534; border: 1px solid #BBF7D0; }
.alert-error   { background: var(--red-light);    color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--orange-light); color: #9A3412; border: 1px solid #FED7AA; }
.alert-info    { background: var(--blue-light);   color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── DETAIL SECTIONS ────────────────────────────────────────── */
.detail-section { margin-bottom: 28px; }
.detail-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 20px;
}
.detail-field-label { font-size: 11px; font-weight: 600; color: var(--gray-400); margin-bottom: 2px; text-transform: uppercase; }
.detail-field-value { font-size: 13.5px; color: var(--gray-800); }

/* ── KEY DISPLAY ────────────────────────────────────────────── */
.license-key {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  letter-spacing: .1em;
  padding: 10px 16px;
  background: var(--gray-900);
  color: #86EFAC;
  border-radius: var(--radius);
  display: inline-block;
}

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1E3A5F 100%);
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
}
.login-logo-text { font-size: 22px; font-weight: 800; color: var(--gray-900); }
.login-logo-sub  { font-size: 12px; color: var(--gray-400); text-align: center; margin-top: -4px; }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: .4; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state-text  { font-size: 13px; }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  width: 480px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--gray-400); font-size: 20px; line-height: 1; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
