:root {
    --bg: #1e1f22;
    --bg-raised: #2b2d31;
    --bg-input: #1e1f22;
    --border: #3f4147;
    --text: #f2f3f5;
    --text-muted: #949ba4;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --danger: #da373c;
    --danger-hover: #a12828;
    --success: #23a55a;
}

* {
    box-sizing: border-box;
}

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

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

.muted {
    color: var(--text-muted);
}

/* Login page */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    max-width: 360px;
}

.login-card h1 {
    margin-top: 0;
}

/* Layout */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    font-weight: 700;
    font-size: 16px;
}

.user-name {
    color: var(--text-muted);
}

.layout {
    display: flex;
    min-height: calc(100vh - 53px);
}

.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.nav-item:hover {
    background: #35373c;
    color: var(--text);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

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

.content h2 {
    margin-top: 0;
}

/* Forms */

.field-group {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.field-group h3 {
    margin-top: 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.field {
    margin-bottom: 14px;
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.field-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-checkbox label {
    margin-bottom: 0;
    font-weight: 400;
}

.field.hidden {
    display: none;
}

.day-checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.day-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
}

input[type="text"], input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    max-width: 480px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 14px;
}

textarea {
    font-family: inherit;
    resize: vertical;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Buttons */

.btn {
    background: #3f4147;
    color: var(--text);
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
}

.btn:hover {
    background: #4a4d53;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    display: inline-block;
}

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

.btn-large {
    padding: 12px 20px;
    font-size: 15px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
}

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

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

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

.save-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.save-status {
    color: var(--success);
}

.rr-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.rr-row .rr-emoji, .rr-row .rr-add-emoji {
    max-width: 160px;
}

.rr-row .rr-role, .rr-row .rr-add-role {
    max-width: 220px;
}

.emoji-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.emoji-picker-btn {
    font-size: 16px;
    line-height: 1;
    padding: 6px 8px;
}

.emoji-picker-popover {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 280px;
    z-index: 20;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.emoji-picker-popover.hidden {
    display: none;
}

.emoji-picker-search {
    max-width: none !important;
    font-size: 13px;
    padding: 5px 8px !important;
}

.emoji-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
}

.emoji-picker-label {
    width: 100%;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-top: 4px;
}

.emoji-picker-label:first-child {
    margin-top: 0;
}

.emoji-picker-label.hidden {
    display: none;
}

.emoji-option {
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 3px;
    cursor: pointer;
    line-height: 0;
}

.emoji-option:hover {
    background: #3f4147;
}

.emoji-option.hidden {
    display: none;
}

.emoji-option img {
    width: 22px;
    height: 22px;
    display: block;
}

.emoji-option-standard {
    font-size: 18px;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tables */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

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

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.badge-green {
    background: rgba(35, 165, 90, 0.15);
    color: var(--success);
}

.badge-red {
    background: rgba(218, 55, 60, 0.15);
    color: var(--danger);
}

/* Analytics */

.analytics-filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.analytics-filter-row .field {
    margin-bottom: 0;
}

.analytics-filter-row input[type="date"] {
    width: auto;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-tile {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.stat-tile-value {
    font-size: 22px;
    font-weight: 600;
}

.stat-tile-label {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.chart-card h3 {
    margin-top: 0;
}

.trend-chart {
    display: block;
    overflow: visible;
}

.chart-baseline {
    stroke: var(--border);
    stroke-width: 1;
}

.bar-label {
    fill: var(--text-muted);
    font-size: 9px;
}

.chart-caption {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}

.breakdown-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.breakdown-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.breakdown-list li:last-child {
    border-bottom: none;
}
