/* DERS Solution ERP — Stylesheet */
:root {
    --bg: #f6f7f9;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-bg: #eff6ff;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info: #0891b2;
    --info-bg: #cffafe;
    --sidebar-bg: #1f2937;
    --sidebar-text: #d1d5db;
    --sidebar-active: #2563eb;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
}
.brand-name { color: white; font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--text-light); font-size: 11px; }

.nav { flex: 1; padding: 8px 6px; overflow-y: auto; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: white; }
.nav a.active { background: var(--sidebar-active); color: white; }
.nav .ico { display: inline-block; width: 16px; text-align: center; opacity: 0.8; }
.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    padding: 12px 12px 6px;
    margin-top: 4px;
}
.sidebar-foot {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 11px;
    color: var(--text-light);
}

.main { flex: 1; min-width: 0; }
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; }
.topbar-actions { display: flex; gap: 8px; }

.content { padding: 20px 24px; max-width: 1400px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { margin: 0; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.stat-value { font-size: 22px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat.stat-danger .stat-value { color: var(--danger); }
.stat.stat-success .stat-value { color: var(--success); }
.stat.stat-warning .stat-value { color: var(--warning); }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}
.table th {
    text-align: left;
    padding: 10px 14px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}
.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: #f3f4f6; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}
label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="password"], input[type="tel"], select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: white;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea { resize: vertical; min-height: 70px; }
.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* Flash messages */
.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid;
}
.flash-success { background: var(--success-bg); color: var(--success); border-color: #86efac; }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: #67e8f9; }

/* Login */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}
.login-box {
    width: 360px;
    background: white;
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-box h1 { text-align: center; margin-bottom: 6px; }
.login-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }

/* Invoice items table */
.items-table { width: 100%; margin-bottom: 14px; }
.items-table th { text-align: left; padding: 6px; font-size: 11px; color: var(--text-muted); }
.items-table td { padding: 4px; }
.items-table input { padding: 5px 8px; font-size: 13px; }

/* Two-column layout */
.row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) {
    .row { grid-template-columns: 1fr; }
    .sidebar { width: 60px; }
    .brand-name, .brand-sub, .nav a span:not(.ico), .nav-section, .sidebar-foot { display: none; }
}

/* Invoice preview */
.invoice-preview {
    background: white;
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    color: #111;
    font-size: 13px;
}
.invoice-preview .header-row { display: flex; justify-content: space-between; margin-bottom: 30px; }
.invoice-preview .company { font-size: 11px; color: #555; }
.invoice-preview .invoice-meta { text-align: right; }
.invoice-preview .meta-table { margin-top: 20px; }
.invoice-preview .meta-table td { padding: 2px 0; }
.invoice-preview .items {
    width: 100%; border-collapse: collapse; margin: 20px 0;
}
.invoice-preview .items th, .invoice-preview .items td {
    padding: 8px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}
.invoice-preview .items .num { text-align: right; }
.invoice-preview .totals { margin-left: auto; width: 280px; }
.invoice-preview .totals td { padding: 4px 8px; }
.invoice-preview .totals .grand { font-weight: 700; border-top: 2px solid #111; font-size: 15px; }

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal-day-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px;
    text-transform: uppercase;
    text-align: center;
}
.cal-day {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    min-height: 90px;
    font-size: 12px;
}
.cal-day.other-month { background: #fafafa; color: var(--text-light); }
.cal-day.today { border-color: var(--primary); background: var(--primary-bg); }
.cal-day-num { font-weight: 600; margin-bottom: 4px; }
.cal-event {
    background: var(--primary-bg);
    color: var(--primary-dark);
    padding: 2px 5px;
    border-radius: 3px;
    margin-bottom: 2px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tasks */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}
.task-item.done { opacity: 0.5; }
.task-item.done .task-title { text-decoration: line-through; }
.task-priority { width: 4px; align-self: stretch; border-radius: 2px; }
.task-priority.low { background: var(--text-light); }
.task-priority.medium { background: var(--info); }
.task-priority.high { background: var(--warning); }
.task-priority.urgent { background: var(--danger); }
.task-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Notes */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.note {
    background: #fef9c3;
    border-radius: var(--radius);
    padding: 12px;
    min-height: 140px;
    font-size: 13px;
    position: relative;
}
.note.color-blue { background: #dbeafe; }
.note.color-green { background: #d1fae5; }
.note.color-pink { background: #fce7f3; }
.note.color-gray { background: #f3f4f6; }
.note h3 { font-size: 13px; margin-bottom: 6px; }
.note-date { position: absolute; bottom: 6px; right: 8px; font-size: 10px; color: rgba(0,0,0,0.4); }

/* Empty state */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 30px; margin-bottom: 8px; opacity: 0.4; }

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Print */
@media print {
    .sidebar, .topbar, .form-actions, .no-print { display: none !important; }
    .main, .content { padding: 0; margin: 0; max-width: 100%; }
    .invoice-preview { box-shadow: none; padding: 0; }
}
