:root {
  --header-height: 72px;
  --sidebar-width: 278px;
  --bg: #f5f8f4;
  --surface: #ffffff;
  --surface-soft: #eef6ee;
  --text: #173226;
  --muted: #66766d;
  --line: #dbe7dd;
  --primary: #11643c;
  --primary-strong: #0a4428;
  --primary-soft: #dff2e6;
  --accent: #8fd16a;
  --warning: #c98a1e;
  --shadow: 0 18px 50px rgba(18, 62, 39, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #0c1511;
  --surface: #121f18;
  --surface-soft: #172a20;
  --text: #edf7f0;
  --muted: #a9b8ae;
  --line: #263a2f;
  --primary: #54ba78;
  --primary-strong: #9ce0ad;
  --primary-soft: #1f3c2a;
  --accent: #b6e27e;
  --warning: #f1b84d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(143, 209, 106, 0.22), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--surface-soft));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  width: 100%;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(90deg, #083f27 0%, #137345 54%, #a4df7b 100%);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(8, 63, 39, 0.22);
}

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

.user-chip {
  display: inline-flex;
  max-width: 240px;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 800;
}

.user-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-logo,
.login-logo {
  display: inline-flex;
  width: 114px;
  height: 63px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}

.brand-logo img,
.login-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  overflow: hidden;
  font-size: 18px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

/* Permission Request Buttons */
.permission-request-button {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  transition: all 160ms ease;
  animation: permission-pulse 3s ease-in-out infinite;
  cursor: pointer;
}

.permission-request-button:hover {
  border-color: rgba(255, 255, 255, 0.52);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.permission-request-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.permission-request-button.is-hidden {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  flex-basis: 0 !important;
}

@keyframes permission-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3);
  }
  50% {
    opacity: 0.95;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.1);
  }
}

/* Location Permission Button - Mavi */
.permission-request-location {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  border-color: rgba(255, 255, 255, 0.28);
}

:root[data-theme="dark"] .permission-request-location {
  background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 100%);
}

.permission-request-location:hover {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

/* Notification Permission Button - Turuncu */
.permission-request-notification {
  background: linear-gradient(135deg, #b45309 0%, #f97316 100%);
  border-color: rgba(255, 255, 255, 0.28);
}

:root[data-theme="dark"] .permission-request-notification {
  background: linear-gradient(135deg, #fb923c 0%, #fed7aa 100%);
}

.permission-request-notification:hover {
  background: linear-gradient(135deg, #92400e 0%, #ea580c 100%);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

.theme-icon-dark,
:root[data-theme="dark"] .theme-icon-light {
  display: none;
}

:root[data-theme="dark"] .theme-icon-dark {
  display: block;
}

.notification-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #f2b84b;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 3px;
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  padding: 0 4px;
}

.mobile-menu-button {
  display: none;
}

.app-sidebar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  z-index: 30;
  width: var(--sidebar-width);
  padding: 20px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 8px 0 30px rgba(18, 62, 39, 0.06);
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-link,
.submenu-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link {
  min-height: 46px;
  padding: 11px 12px;
  background: transparent;
  font-weight: 700;
}

.nav-link:hover,
.submenu-link:hover {
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.nav-link.is-active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(17, 100, 60, 0.2);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.nav-group-toggle {
  justify-content: flex-start;
}

.chevron {
  width: 18px;
  height: 18px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.nav-group.is-open .chevron {
  transform: rotate(90deg);
}

.submenu {
  display: grid;
  max-height: 0;
  gap: 4px;
  margin-left: 24px;
  overflow: hidden;
  transition: max-height 180ms ease, padding 180ms ease;
}

.nav-group.is-open .submenu {
  max-height: 140px;
  padding: 6px 0 4px;
}

.submenu-link {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 650;
}

.submenu-link.is-active {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.sidebar-backdrop {
  position: fixed;
  inset: var(--header-height) 0 0 0;
  z-index: 25;
  display: none;
  background: rgba(8, 31, 20, 0.48);
}

.app-main {
  min-height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  padding: 32px;
}

.page-heading {
  margin-bottom: 22px;
}

.page-heading p,
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

.content-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.empty-state h2 {
  margin: 0;
  font-size: 20px;
}

.panel-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  padding: 34px;
}

.empty-state p {
  max-width: 620px;
  margin: 10px 0 22px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 800;
  line-height: 1.2;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  color: #ffffff;
}

.btn-secondary {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
}

.alert {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(18, 62, 39, 0.08);
  font-weight: 750;
}

.alert a {
  color: var(--primary);
  text-decoration: underline;
}

.alert-success {
  border-color: color-mix(in srgb, var(--primary) 36%, var(--line));
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.alert-danger {
  border-color: color-mix(in srgb, #c34343 38%, var(--line));
  background: color-mix(in srgb, #c34343 12%, var(--surface));
  color: #9a2626;
}

:root[data-theme="dark"] .alert-danger {
  color: #ffb7b7;
}

.form-panel {
  margin-bottom: 24px;
}

.user-form-panel {
  display: none;
}

.user-form-panel.is-open {
  display: block;
}

.record-form {
  padding: 22px;
}

.form-section {
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  padding-bottom: 22px;
}

.form-section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.form-section h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field,
.toggle-field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span,
.toggle-field span {
  color: var(--text);
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.toolbar-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.password-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.password-control input {
  min-width: 0;
}

.field-icon-button {
  width: 42px;
  height: 42px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.field-icon-button:hover,
.field-icon-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
}

.field .is-invalid,
.login-form .is-invalid {
  border-color: #c34343;
}

.field-error {
  margin: 0;
  color: #c34343;
  font-size: 13px;
  font-weight: 750;
}

.toggle-field {
  align-content: end;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 42px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.toolbar-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-toolbar {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.price-actions-panel {
  margin-bottom: 24px;
}

.price-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 18px;
  padding: 22px;
}

.price-toolbar-current {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.bulk-price-form {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.history-select-form {
  width: min(100%, 520px);
  align-items: flex-end;
}

.history-selector-field {
  flex: 1 1 340px;
}

.history-selector-field select {
  width: 100%;
}

.compact-field {
  min-width: 220px;
}

.compact-field select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

.inline-price-form {
  display: block;
  min-width: 130px;
}

.price-input {
  width: 130px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  text-align: right;
}

.price-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
  outline: none;
}

.price-input.is-previewed {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
}

.preview-message {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.preview-message:empty {
  display: none;
}

.preview-message.is-active {
  display: block;
}

.preview-message.is-error {
  color: #c34343;
}

.history-readonly-note {
  min-height: 42px;
  padding: 10px 0;
}

.history-readonly-note strong {
  display: block;
}

.history-page-header {
  align-items: flex-start;
}

.history-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.history-page-actions form {
  margin: 0;
}

.restore-summary-panel {
  margin-bottom: 18px;
}

.restore-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 22px;
}

.restore-summary-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-soft);
}

.restore-summary-grid strong {
  display: block;
  color: var(--primary-strong);
  font-size: 26px;
}

.restore-summary-grid span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.restore-summary-note {
  margin: 0;
  padding: 0 22px 14px;
  color: var(--muted);
  font-weight: 750;
}

.price-table th:last-child,
.price-table td:last-child {
  width: 130px;
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.is-disabled {
  pointer-events: none;
  opacity: 0.48;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 92px 18px 18px;
  background: rgba(8, 31, 20, 0.52);
}

.confirm-modal.is-open {
  display: flex;
}

.confirm-dialog {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-dialog-header {
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
}

.confirm-dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.confirm-dialog-body {
  padding: 18px 20px;
  color: var(--muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.data-table th,
.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.interactive-table tbody tr {
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.interactive-table tbody tr:hover,
.interactive-table tbody tr.is-selected {
  background: var(--primary-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-inline {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface-soft);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--primary-strong);
  font-size: 30px;
}

@media (max-width: 920px) {
  .app-header {
    padding: 0 16px;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .brand-text {
    max-width: 45vw;
  }

  .user-chip {
    display: none;
  }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .app-main {
    margin-left: 0;
    padding: 24px 16px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .header-actions {
    gap: 8px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .brand-text {
    display: none;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .toolbar-form,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .price-toolbar {
    grid-template-columns: 1fr;
  }

  .price-toolbar-current,
  .history-select-form,
  .history-page-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .restore-summary-grid {
    grid-template-columns: 1fr;
  }

  .compact-field,
  .history-selector-field,
  .inline-price-form,
  .price-input {
    width: 100%;
    min-width: 0;
  }

  .permission-request-button {
    width: 38px;
    height: 38px;
  }
}

/* Toast Notifications */
@keyframes slideInUp {
  from {
    transform: translateY(120%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(120%);
    opacity: 0;
  }
}

[data-permission-toast] {
  font-size: 14px;
  line-height: 1.4;
}

[data-permission-toast].permission-toast-error {
  background: #ef4444;
  color: white;
}

[data-permission-toast].permission-toast-success {
  background: #22c55e;
  color: white;
}
