/* ================================================================
   Narzędzia Semhub — Old Money Moderne
   Palette: #111110 (bg), #C4874A (gold), #1C1C1B (surface),
            #2A2A28 (elevated), #E8E4DC (cream text)
   Typography: Cormorant Garamond (headings), Manrope (body)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Manrope:wght@300;400;500;600&display=swap');

:root {
  --bg:           #111110;
  --surface:      #1C1C1B;
  --elevated:     #2A2A28;
  --border:       #333330;
  --border-light: #3D3D3A;
  --gold:         #C4874A;
  --gold-light:   #D4975A;
  --gold-dim:     #8A5E33;
  --cream:        #E8E4DC;
  --cream-muted:  #A8A49C;
  --cream-dim:    #6A6660;
  --danger:       #8B3A3A;
  --success:      #3A6B4A;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Manrope', Arial, sans-serif;
  --radius:       4px;
  --radius-lg:    8px;
  --shadow:       0 2px 12px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.6);
  --transition:   160ms ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--cream);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  letter-spacing: .03em;
  color: var(--cream);
}

h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 300; }
h2 { font-size: clamp(1.3rem, 2vw, 1.8rem); }
h3 { font-size: 1.2rem; }

p, li { color: var(--cream-muted); font-weight: 300; }

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* ── Layout ─────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--cream);
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo span {
  color: var(--gold);
  font-style: italic;
}

.topbar-spacer { flex: 1; }

.topbar-user {
  font-size: .8rem;
  color: var(--cream-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user a {
  color: var(--cream-dim);
  font-size: .75rem;
}

.topbar-user a:hover { color: var(--gold); }

/* ── Sidebar ─────────────────────────────────────────────────── */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 16px;
  margin-bottom: 28px;
}

.sidebar-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--cream-dim);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--cream-muted);
  font-size: .875rem;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--elevated);
  color: var(--cream);
}

.nav-item.active {
  background: var(--elevated);
  color: var(--gold);
  border-color: var(--border-light);
}

.nav-item .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  color: var(--gold-dim);
  flex-shrink: 0;
}

.nav-item.active .nav-icon { color: var(--gold); }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

/* ── Main content ───────────────────────────────────────────── */

.main-content {
  overflow-y: auto;
  padding: 32px 36px;
  background: var(--bg);
}

.page-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin-bottom: 4px;
}

.page-header p {
  font-size: .9rem;
  color: var(--cream-dim);
}

.breadcrumb {
  font-size: .78rem;
  color: var(--cream-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--cream-dim); }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { color: var(--border-light); }

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-light); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--cream);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Stats strip ─────────────────────────────────────────────── */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-align: center;
}

.stat-box .stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 300;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-box .stat-label {
  font-size: .75rem;
  color: var(--cream-dim);
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
}
.btn-primary:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--cream-muted);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: var(--elevated);
  color: var(--cream);
  border-color: var(--cream-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border-color: transparent;
  padding: 9px 12px;
}
.btn-ghost:hover {
  background: var(--elevated);
}

.btn-danger {
  background: transparent;
  color: #E06C6C;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: var(--cream);
}

.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 12px 28px; font-size: .95rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--cream-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="color"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: .9rem;
  transition: border-color var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold-dim);
}

textarea { resize: vertical; min-height: 80px; }

input[type="color"] {
  padding: 4px 8px;
  height: 40px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: .75rem;
  color: var(--cream-dim);
  margin-top: 4px;
}

/* ── Tables ─────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead tr {
  border-bottom: 1px solid var(--border-light);
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:hover { background: var(--surface); }

tbody td {
  padding: 11px 14px;
  color: var(--cream-muted);
  vertical-align: middle;
}

tbody td:first-child { color: var(--cream); }

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.badge-pending   { background: #2A2510; color: #C4A45A; border: 1px solid #4A3A10; }
.badge-ok        { background: #102A18; color: #5AC47A; border: 1px solid #1A4A28; }
.badge-error     { background: #2A1010; color: #C45A5A; border: 1px solid #4A1818; }
.badge-skip      { background: var(--elevated); color: var(--cream-dim); border: 1px solid var(--border); }
.badge-gold      { background: #2A1C0A; color: var(--gold); border: 1px solid var(--gold-dim); }

/* ── Tabs ───────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: .85rem;
  color: var(--cream-dim);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-body);
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--cream-muted); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts ─────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert-success {
  background: #0D1F13;
  border-color: #1A4A28;
  color: #6AC47A;
}

.alert-error {
  background: #1F0D0D;
  border-color: #4A1818;
  color: #C46A6A;
}

.alert-info {
  background: #0D161F;
  border-color: #183048;
  color: #6AA4C4;
}

/* ── Gold divider ───────────────────────────────────────────── */

.gold-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  border: none;
  margin: 28px 0;
}

/* ── Loading spinner ─────────────────────────────────────────── */

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Ornament ───────────────────────────────────────────────── */

.ornament {
  color: var(--gold-dim);
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1.1rem;
  letter-spacing: .1em;
}

/* ── Toast ──────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--cream);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast.toast-ok   { border-color: var(--success); }
#toast.toast-err  { border-color: var(--danger); }

/* ── Login page ─────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, #1C1810 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, #1A1208 0%, transparent 50%);
}

.login-box {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: .12em;
}

.login-logo .subtitle {
  font-size: .75rem;
  color: var(--cream-dim);
  letter-spacing: .15em;
  text-transform: uppercase;
  margin-top: 6px;
}

.login-ornament {
  text-align: center;
  color: var(--gold);
  font-size: 1.4rem;
  margin-bottom: 8px;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cream-dim); }
