@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&family=Lato:wght@300;400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #f0f2f7;
  --border: #e0e4ef;
  --accent: #2ECC71;
  --accent2: #9A94E0;
  --danger: #e53e3e;
  --warn: #F07622;
  --text: #1a202c;
  --muted: #718096;
}

body { background: var(--bg); color: var(--text); font-family: 'Lato', system-ui, sans-serif; font-size: 14px; min-height: 100vh; }

/* Layout */
.layout { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.main { display: flex; flex-direction: column; overflow: hidden; }
.main-scroll { flex: 1; overflow-y: auto; padding: 24px; }

/* Sidebar */
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo h1 { font-size: 16px; font-weight: 700; font-family: 'Lexend', sans-serif; display: flex; align-items: center; gap: 8px; }
.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 500; transition: background .15s; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface2); }
.nav-item.active { background: #e8fdf2; border-left: 3px solid var(--accent); }
.nav-item .icon { width: 22px; text-align: center; flex-shrink: 0; font-size: 16px; line-height: 1; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.sidebar-footer a { color: var(--muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--text); }

/* Main header */
.main-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface); flex-shrink: 0; }
.main-header h2 { font-size: 16px; font-weight: 600; font-family: 'Lexend', sans-serif; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

/* Admin sub-nav */
.admin-subnav { display: flex; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; flex-shrink: 0; overflow-x: auto; }
.admin-subnav-group { display: flex; flex-direction: column; padding: 8px 16px 0; border-right: 1px solid var(--border); min-width: 0; }
.admin-subnav-group:first-child { padding-left: 0; }
.admin-subnav-group:last-child { border-right: none; }
.admin-subnav-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; white-space: nowrap; }
.admin-subnav-links { display: flex; gap: 2px; padding-bottom: 8px; }
.admin-subnav-links a { padding: 4px 10px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; transition: all .15s; }
.admin-subnav-links a:hover { background: var(--surface2); color: var(--text); }
.admin-subnav-links a.active { background: #e8fdf2; color: var(--accent); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s; font-family: inherit; text-decoration: none; }
.btn:hover { filter: brightness(0.92); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--accent2); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost.btn-active, .btn-ghost.btn-active:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost-accent { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost-accent:hover { filter: none; background: rgba(46,204,113,.08); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; border-radius: 6px; background: transparent; border: 1px solid var(--border); cursor: pointer; color: var(--muted); transition: all .15s; font-size: 15px; line-height: 1; min-width: 30px; min-height: 30px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card-title { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 16px; letter-spacing: .06em; text-transform: uppercase; font-family: 'Lexend', sans-serif; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-card .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--text); margin: 6px 0; font-family: 'Lexend', sans-serif; }
.stat-card .sub { font-size: 12px; color: var(--muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; letter-spacing: .03em; }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 8px 10px; font-size: 13px; font-family: inherit; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,204,113,0.15); }
textarea { resize: vertical; min-height: 80px; }
input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge-backlog { background: var(--surface2); color: var(--muted); }
.badge-planned { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #fff3e0; color: #b45309; }
.badge-waiting { background: #ede9fe; color: #6d28d9; }
.badge-done { background: #e8fdf2; color: #276749; }
.badge-cancelled { background: #fff5f5; color: #c53030; }
.badge-urgent { background: #fff5f5; color: #c53030; }
.badge-high { background: #fff3e0; color: #b45309; }
.badge-medium { background: #dbeafe; color: #1d4ed8; }
.badge-low { background: var(--surface2); color: var(--muted); }
.badge-someday { background: var(--surface2); color: var(--muted); font-style: italic; }

/* Help-tip: inline ? tooltip icon */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 10px; font-weight: 700; cursor: help;
  position: relative; vertical-align: middle; margin-left: 4px;
  font-family: 'Lato', sans-serif; flex-shrink: 0; line-height: 1;
}
.help-tip::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: #1a202c; color: #fff; padding: 7px 11px; border-radius: 6px;
  font-size: 12px; line-height: 1.5; width: max-content; max-width: 260px;
  white-space: normal; pointer-events: none; opacity: 0; transition: opacity .15s;
  z-index: 9999; font-weight: 400; letter-spacing: 0;
}
.help-tip:hover::after { opacity: 1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 2px solid var(--border); overflow: hidden; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow: hidden; }
tr:hover { background: var(--surface2); }
td a { color: var(--text); text-decoration: none; }
td a:hover { color: var(--accent); }
/* Resizable column handle hover */
table[data-resizable] th { user-select: none; }
table[data-resizable] th span[style*="col-resize"]:hover { background: var(--accent) !important; opacity: .3; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 20px; flex-shrink: 0; }
.tab { padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 500; transition: all .15s; white-space: nowrap; text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.toggle-row label { margin: 0; font-size: 13px; color: var(--text); }
.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; }
input:checked + .toggle-slider { background: var(--accent2); }
input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Pills / Filter chips */
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill { padding: 5px 12px; border-radius: 20px; background: var(--surface2); border: 1px solid var(--border); cursor: pointer; font-size: 12px; transition: all .15s; user-select: none; text-decoration: none; color: var(--text); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 680px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; font-weight: 600; font-family: 'Lexend', sans-serif; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Toast notifications */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 8px; font-size: 13px; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: toast-in .3s ease; }
.toast-success { background: var(--accent); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Status bar */
.status-bar { padding: 6px 12px; background: var(--surface2); border-radius: 6px; font-size: 12px; color: var(--muted); }
.status-bar.error { background: #fff5f5; color: #c53030; border-left: 3px solid var(--danger); }
.status-bar.success { background: #e8fdf2; color: #276749; border-left: 3px solid var(--accent); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--muted); gap: 12px; text-align: center; }
.empty-state .icon { font-size: 40px; opacity: .3; }

/* Loading */
.loading-state { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px 0; color: var(--muted); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Section header */
.section-header { font-size: 12px; font-weight: 600; color: var(--text); border-top: 1px solid var(--border); padding-top: 16px; margin: 20px 0 12px; letter-spacing: .03em; }

/* Quick actions */
.quick-actions { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

/* Filter bar */
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input[type="search"] { max-width: 240px; }
.filter-bar select { max-width: 160px; }

/* Checkbox in tables */
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Login page (full page, no sidebar) */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.login-card h1 { font-family: 'Lexend', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 8px; text-align: center; }
.login-card .subtitle { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 24px; }
.login-card .error-msg { background: #fff5f5; color: #c53030; padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }

/* Activity feed */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.activity-text { flex: 1; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Responsive */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
