:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --color-label: #475569;
  --color-primary: #1e293b;
  --color-primary-hover: #334155;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --sidebar-width: 220px;
  --topbar-height: 52px;
  --sidebar-bg: #f1f5f9;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--color-text); }

/* Auth pages */
.auth-page { background: var(--bg-page); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { background: #fff; padding: 2.5rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); width: 100%; max-width: 400px; }
.auth-card h1 { text-align: center; margin-bottom: 1.5rem; color: var(--color-primary); font-size: 1.5rem; }
.auth-links { text-align: center; margin-top: 1rem; }
.auth-links a { color: var(--color-text-muted); text-decoration: none; font-size: 0.875rem; }
.auth-links a:hover { color: var(--color-primary); }

/* App layout */
.app-page { background: var(--bg-page); min-height: 100vh; }
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh; background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 100; border-right: 1px solid var(--color-border); }
.sidebar-logo { padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); }
.sidebar-logo a { text-decoration: none; }
.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }
.sidebar-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1.25rem; color: var(--color-text-muted); text-decoration: none; font-size: 0.875rem; transition: background 0.15s, color 0.15s; }
.sidebar-link:hover { background: rgba(0,0,0,0.05); color: var(--color-text); }
.sidebar-link.active { background: rgba(0,0,0,0.08); color: var(--color-primary); font-weight: 600; }
.sidebar-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-divider { border: none; border-top: 1px solid var(--color-border); margin: 0.25rem 1rem; }
.sidebar-bottom { border-top: 1px solid var(--color-border); padding: 0.5rem 0; }

.topbar { position: fixed; top: 0; left: var(--sidebar-width); right: 0; height: var(--topbar-height); background: var(--sidebar-bg); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; z-index: 99; }
.topbar-left { }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-user-badge { font-size: 0.875rem; color: var(--color-text-muted); }
.topbar-logout { display: inline; }

.app-content { margin-left: var(--sidebar-width); margin-top: var(--topbar-height); padding: 1.5rem 2rem; }

/* Forms */
.form-card { background: var(--bg-card); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--color-border); }
.form-section-title { font-size: 1rem; font-weight: 600; color: var(--color-text); margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.875rem; color: var(--color-label); }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; padding: 0.5rem 0.625rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.875rem; background: var(--bg-input); color: var(--color-text); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(30,41,59,0.1); }
.form-help { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.form-help code { background: #e2e8f0; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.75rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

.color-picker-row { display: flex; align-items: center; gap: 0.5rem; }
.color-picker-row input[type="color"] { width: 36px; height: 36px; border: 1px solid var(--color-border); border-radius: 4px; padding: 2px; cursor: pointer; }
.color-hex-input { width: 90px !important; font-family: monospace; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: #e2e8f0; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-active { background: #e2e8f0; border-color: var(--color-primary); }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: #fef2f2; color: var(--color-error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; }

/* Sidebar logo image */
.sidebar-logo-img { max-width: 100%; height: auto; display: block; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 0; }
.tab { padding: 0.5rem 1.25rem; background: #e2e8f0; color: var(--color-text-muted); text-decoration: none; font-size: 0.875rem; font-weight: 500; border: 1px solid var(--color-border); border-bottom: none; border-radius: 6px 6px 0 0; margin-right: -1px; transition: background 0.15s, color 0.15s; }
.tab:hover { background: #f8fafc; color: var(--color-text); }
.tab.active { background: var(--bg-card); color: var(--color-text); border-bottom: 1px solid var(--bg-card); z-index: 1; position: relative; }

/* Tab panel */
.tab-panel { background: var(--bg-card); border: 1px solid var(--color-border); border-radius: 0 8px 8px 8px; padding: 1.5rem; }
.tab-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table thead { background: #f8fafc; }
.data-table th { text-align: left; padding: 0.6rem 1rem; font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid var(--color-border); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.025em; }
.data-table td { padding: 0.6rem 1rem; border-bottom: 1px solid #f1f5f9; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.table-empty { text-align: center; color: var(--color-text-muted); padding: 2rem 1rem !important; }
.th-actions { width: 1%; white-space: nowrap; }
.td-actions { white-space: nowrap; text-align: right; }

/* Icon buttons */
.btn-icon-sm { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: none; background: transparent; color: var(--color-text-muted); border-radius: 4px; cursor: pointer; text-decoration: none; transition: background 0.15s, color 0.15s; }
.btn-icon-sm:hover { background: #f1f5f9; color: var(--color-text); }
.btn-icon-danger:hover { background: #fef2f2; color: var(--color-error); }

/* Inline form */
.inline-form { background: #f8fafc; border: 1px solid var(--color-border); border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 1rem; }

/* Danger button */
.btn-danger { background: transparent; border: 1px solid #fecaca; color: var(--color-error); }
.btn-danger:hover { background: #fef2f2; }

/* Form section */
.form-section { margin-bottom: 1.5rem; }
.form-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--color-text); }

/* User filters */
.user-filters { display: flex; gap: 0.75rem; align-items: center; }
.filter-input { padding: 0.4rem 0.625rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.8rem; width: 250px; background: var(--bg-input); }
.filter-select { padding: 0.4rem 0.625rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.8rem; background: var(--bg-input); }

/* Filter bar */
.filter-bar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-checkbox { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--color-text-muted); cursor: pointer; white-space: nowrap; }
.filter-checkbox input { cursor: pointer; }

/* Status badges */
.status-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.status-judgment { background: #dbeafe; color: #1e40af; }
.status-filtered { background: #f1f5f9; color: #64748b; }
.status-satisfied { background: #dcfce7; color: #166534; }
.status-vacated { background: #fef3c7; color: #92400e; }

/* Table sort & filter */
.sortable-th { cursor: pointer; user-select: none; position: relative; }
.sortable-th:hover { background: #f1f5f9; }
.sort-arrow { font-size: 0.7rem; color: var(--color-text-muted); }
.sort-active { color: var(--color-primary); }
.sort-active .sort-arrow { color: var(--color-primary); }
.table-filter-row { background: var(--bg-card); }
.table-filter-cell { padding: 0.375rem 0.5rem !important; border-bottom: 1px solid var(--color-border) !important; }
.table-filter-input { width: 100%; padding: 0.3rem 0.5rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.8125rem; font-family: inherit; color: var(--color-text); background: #f8fafc; transition: border-color 0.15s; }
.table-filter-input::placeholder { color: #cbd5e1; }
.table-filter-input:focus { outline: none; border-color: var(--color-primary); background: #fff; box-shadow: 0 0 0 2px rgba(30,41,59,0.1); }

/* Status checkboxes */
.status-checkboxes { display: flex; gap: 1rem; align-items: center; }
.status-checkboxes .filter-checkbox { gap: 0.25rem; }

/* Content header */
.content-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.back-link { font-size: 0.8rem; color: var(--color-text-muted); text-decoration: none; }
.back-link:hover { color: var(--color-primary); }

/* Detail card */
.detail-card { background: var(--bg-card); border: 1px solid var(--color-border); border-radius: 8px; margin-bottom: 0.75rem; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.detail-section { padding: 1rem 1.25rem; }
.detail-section:not(:last-child) { border-right: 1px solid var(--color-border); }
.detail-section h2 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.detail-row { display: flex; padding: 0.3rem 0; border-bottom: 1px solid #f8fafc; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 110px; flex-shrink: 0; font-size: 0.8rem; color: var(--color-text-muted); }
.detail-value { font-size: 0.875rem; color: var(--color-text); }
.detail-meta { padding: 0.5rem 1.25rem; border-top: 1px solid var(--color-border); display: flex; gap: 2rem; font-size: 0.75rem; color: var(--color-text-muted); }

/* Clickable table rows */
.table-row-link { cursor: pointer; }
.table-row-link:hover { background: #f1f5f9 !important; }
.td-primary { font-weight: 600; color: var(--color-primary); }
