/* Hubuntu-style admin panel */
:root {
  --sidebar-bg: #1e293b;
  --sidebar-width: 260px;
  --header-bg: #5b21b6;
  --header-height: 56px;
  --accent-active: #f97316;
  --content-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Layout: sidebar + main */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-profile {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}
.sidebar-name { font-weight: 500; font-size: 14px; }
.sidebar-role { font-size: 12px; color: #94a3b8; }
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left: 3px solid var(--accent-active);
  padding-left: 17px;
}
.sidebar-nav a.active .nav-icon { color: var(--accent-active); }
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.header {
  height: var(--header-height);
  background: var(--header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.header-title { font-size: 18px; font-weight: 600; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-actions a {
  color: rgba(255,255,255,0.9);
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  transition: background 0.15s;
}
.header-actions a:hover { background: rgba(255,255,255,0.15); }
.header-actions .icon { width: 18px; height: 18px; }

.content {
  flex: 1;
  padding: 24px;
  overflow-auto;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-primary);
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 20px 0;
  color: var(--text-primary);
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--header-bg);
  box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.15);
}
.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--header-bg);
  color: #fff;
}
.btn-primary:hover { background: #6d28d9; }
.btn-secondary {
  background: #e2e8f0;
  color: var(--text-primary);
}
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table td[contenteditable="true"] {
  min-width: 80px;
  outline: none;
}
.data-table td[contenteditable="true"]:focus {
  background: #fef3c7;
  box-shadow: inset 0 0 0 1px var(--accent-active);
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.search-bar .form-control { max-width: 320px; margin: 0; }
.search-hint { font-size: 13px; color: var(--text-muted); }
.search-bar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* Login page (centered, no sidebar) */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--header-bg) 100%);
  padding: 20px;
}
.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: var(--text-primary);
}
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* Dashboard quick links */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.dash-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s;
  display: block;
}
.dash-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c7d2fe;
}
.dash-card h3 { margin: 0 0 8px 0; font-size: 16px; }
.dash-card p { margin: 0; font-size: 13px; color: var(--text-muted); }
.dash-card .dash-icon { margin-bottom: 12px; color: var(--header-bg); }

/* Users table actions */
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-actions form { display: inline; }

/* Clients toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Invoice status */
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  border-top-color: var(--header-bg);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-error {
  color: var(--danger);
  font-weight: 500;
  font-size: 13px;
}

/* Log panel */
.log-box {
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 12px;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.log-lines {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
}
.log-line { padding: 2px 0; }
.log-error { color: #fecaca; }
