:root {
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;

  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);

  --bg-page: #fafafa;
  --bg-surface: #ffffff;
  --bg-muted: #f3f4f6;
  --border-soft: #e5e7eb;

  --text-main: #0f172a;
  --text-body: #595959;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --cta: #10b981;
  --cta-hover: #059669;

  --crm-sidebar-width: 300px;
  --crm-content-gap: 24px;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  overflow-x: hidden;
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  color: var(--text-body);
  background: var(--bg-page);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 var(--space-2);
}

p,
li,
label,
td,
th {
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary);
}

main.crm-main-content {
  margin-left: calc(var(--crm-sidebar-width) + var(--crm-content-gap));
  width: calc(100% - var(--crm-sidebar-width) - (var(--crm-content-gap) * 2));
  margin-top: var(--space-4);
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-bottom: var(--space-5);
}

header.crm-header-offset {
  margin-left: calc(var(--crm-sidebar-width) + var(--crm-content-gap)) !important;
  width: calc(100% - var(--crm-sidebar-width) - (var(--crm-content-gap) * 2));
  padding: var(--space-2) var(--space-3) !important;
  margin-top: var(--space-3);
  position: relative;
  z-index: 1;
  min-width: 0;
}

.crm-container,
.desktop-toolbar-wrap {
  width: 100%;
}

.crm-container {
  margin: 0 auto;
  max-width: 1200px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  padding-bottom: var(--space-3);
}

.crm-table-wrapper {
  overflow-x: auto;
}

img {
  max-width: 100%;
  height: auto;
}

section,
.card,
.crm-container,
.table,
.calendar-grid,
.desktop-toolbar {
  margin-bottom: var(--space-4);
}

button,
.btn,
.crm-btn {
  font-family: inherit;
  border-radius: var(--radius-md) !important;
  transition: all 0.2s ease;
}

.btn,
.crm-btn {
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: none;
}

.btn:hover,
.crm-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary,
.crm-btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.btn-primary:hover,
.crm-btn-primary:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}

.btn-success {
  background: var(--cta) !important;
  border-color: var(--cta) !important;
}

.btn-success:hover {
  background: var(--cta-hover) !important;
  border-color: var(--cta-hover) !important;
}

.form-control,
.form-select,
.desktop-toolbar-input,
.desktop-toolbar-select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: #fff;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus,
.desktop-toolbar-input:focus,
.desktop-toolbar-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16) !important;
  outline: none;
}

table,
.table,
.crm-table {
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.table th,
.table td,
.crm-table th,
.crm-table td {
  padding: 12px 14px !important;
  border-color: #eef2f7 !important;
  vertical-align: middle;
}

.table th,
.crm-table th {
  background: #f8fafc;
  color: var(--text-main);
  font-weight: 700;
}

.table tbody tr,
.crm-table tbody tr {
  transition: background 0.2s ease;
}

.table tbody tr:hover,
.crm-table tbody tr:hover {
  background: #f8fafc;
}

.stat-item,
.desktop-toolbar,
.calendar-header,
.calendar-grid {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-md);
}

.status-badge {
  border-radius: 999px !important;
  padding: 4px 10px !important;
  font-weight: 700;
  font-size: 12px;
}

.alert {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-surface: #1b1b1b;
    --bg-muted: #222;
    --border-soft: #2f2f2f;
    --text-main: #595959;
    --text-body: #595959;
    --text-muted: #595959;
  }

  body {
    background: var(--bg-page);
    color: var(--text-body);
  }
}
