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

:root {
  --sidebar-width: 220px;
  --header-height: 48px;
  --accent: #5c6bc0;
  --accent-hover: #3f51b5;
  --danger: #e53935;
  --danger-hover: #c62828;
  --bg: #f4f6f8;
  --card: #fff;
  --border: #e0e0e0;
  --text: #333;
  --text-light: #777;
  --sidebar-bg: #fff;
  --sidebar-active: #eef0ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* === Gradient Header Bar === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, #5c6bc0 0%, #7b1fa2 40%, #e53935 100%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  z-index: 100;
}

.topbar .user-info {
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .user-info .avatar {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.topbar .user-info a {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  margin-left: 12px;
}

.topbar .user-info a:hover {
  color: #fff;
  text-decoration: none;
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 8px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 450;
  transition: background 0.15s;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-active);
  text-decoration: none;
}

.sidebar-nav li a.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav li a .icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.7;
}

.sidebar-nav li a.active .icon {
  opacity: 1;
}

/* === Main Content === */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 28px 32px;
  min-height: calc(100vh - var(--header-height));
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111;
}

.page-subtitle {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 24px;
}

/* === Breadcrumb === */
.breadcrumb {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--accent); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 5px 8px;
  font-size: 14px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 4px;
}
.btn-icon:hover { background: #f0f0f0; color: var(--text); }

/* === Card / Panel === */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

/* === Table === */
.table-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: #fafafa;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #fafbfc;
}

.table-footer {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: #fafafa;
}

.table-footer strong {
  color: var(--accent);
}

/* === Upload bar === */
.upload-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.upload-bar .card-title {
  margin-bottom: 12px;
}

.upload-bar form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-bar select,
.upload-bar input[type="file"] {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}

.upload-bar select {
  min-width: 200px;
}

/* === Action cells === */
.actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.actions a, .actions button {
  font-size: 12px;
}

.inline-form { display: inline; }

/* === Dashboard Stats === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

/* === Add client form (inline) === */
.add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-form input[type="text"] {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  width: 260px;
}

/* === Login page === */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5c6bc0 0%, #7b1fa2 40%, #e53935 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: #111;
}

.login-card .login-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.15s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.12);
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
  margin-top: 8px;
}

.login-card .error {
  background: #ffeaea;
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
}

.login-footer {
  margin-top: 32px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}

/* === Dropdown Menu === */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  color: var(--text-light);
  border-radius: 4px;
  letter-spacing: 2px;
  line-height: 1;
}

.dropdown-toggle:hover { background: #f0f0f0; }

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 50;
  overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a,
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: #f5f5f5;
  text-decoration: none;
}

.dropdown-menu .text-danger { color: var(--danger); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* === URL link style === */
.url-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 13px;
}

/* === Modal (for add client) === */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal .form-group {
  margin-bottom: 16px;
}

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
}

.modal input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.modal input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.12);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* === Footer (Q logo) === */
.app-footer {
  position: fixed;
  bottom: 12px;
  right: 16px;
  z-index: 50;
}

.q-badge {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}
