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

:root {
	--primary: #1a56db;
	--primary-dark: #1246b5;
	--primary-light: #e8f0fe;
	--danger: #dc2626;
	--danger-light: #fef2f2;
	--gray-50: #f9fafb;
	--gray-100: #f3f4f6;
	--gray-200: #e5e7eb;
	--gray-300: #d1d5db;
	--gray-400: #9ca3af;
	--gray-500: #6b7280;
	--gray-600: #4b5563;
	--gray-700: #374151;
	--gray-800: #1f2937;
	--gray-900: #111827;
	--radius: 8px;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
	--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
	--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: var(--gray-50);
	color: var(--gray-800);
	line-height: 1.5;
	font-size: 14px;
}

/* ── Header ──────────────────────────────────────────────────────── */
.app-header {
	background: white;
	border-bottom: 1px solid var(--gray-200);
	padding: 0 24px;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: var(--shadow);
}

.logo {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 700;
	font-size: 16px;
	color: var(--primary);
}

.logo span {
	color: var(--gray-700);
	font-weight: 400;
}
.header-actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

/* ── Main content ────────────────────────────────────────────────── */
.main-content {
	max-width: 1200px;
	margin: 0 auto;
	padding: 32px 24px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: var(--radius);
	font-size: 14px;
	font-weight: 500;
	border: none;
	cursor: pointer;
	transition: all 0.15s;
	text-decoration: none;
	white-space: nowrap;
	line-height: 1.4;
}

.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.btn-primary {
	background: var(--primary);
	color: white;
}
.btn-primary:hover:not(:disabled) {
	background: var(--primary-dark);
}

.btn-secondary {
	background: white;
	color: var(--gray-700);
	border: 1px solid var(--gray-300);
}
.btn-secondary:hover:not(:disabled) {
	background: var(--gray-50);
	border-color: var(--gray-400);
}

.btn-danger {
	background: var(--danger-light);
	color: var(--danger);
	border: 1px solid #fca5a5;
}
.btn-danger:hover:not(:disabled) {
	background: #fee2e2;
}

.btn-ghost {
	background: transparent;
	color: var(--gray-600);
	border: none;
}
.btn-ghost:hover:not(:disabled) {
	background: var(--gray-100);
}

.btn-sm {
	padding: 5px 10px;
	font-size: 13px;
}
.btn-lg {
	padding: 10px 22px;
	font-size: 15px;
}
.btn-block {
	width: 100%;
	justify-content: center;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
	background: white;
	border-radius: var(--radius);
	border: 1px solid var(--gray-200);
	box-shadow: var(--shadow);
}

.card-header {
	padding: 14px 20px;
	border-bottom: 1px solid var(--gray-200);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.card-body {
	padding: 20px;
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group {
	margin-bottom: 16px;
}

.form-label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--gray-700);
	margin-bottom: 5px;
}

.required {
	color: var(--danger);
	margin-left: 2px;
}

.form-input,
.form-select {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid var(--gray-300);
	border-radius: var(--radius);
	font-size: 14px;
	color: var(--gray-800);
	background: white;
	transition:
		border-color 0.15s,
		box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.form-input.error {
	border-color: var(--danger);
}

.form-error {
	font-size: 12px;
	color: var(--danger);
	margin-top: 4px;
}

.form-hint {
	font-size: 12px;
	color: var(--gray-500);
	margin-top: 4px;
}

.form-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
}

.form-row .full-width {
	grid-column: 1 / -1;
}

.form-actions {
	display: flex;
	gap: 12px;
	padding-top: 16px;
}

/* ── Alert ───────────────────────────────────────────────────────── */
.alert {
	padding: 12px 16px;
	border-radius: var(--radius);
	font-size: 14px;
	margin-bottom: 16px;
}

.alert-error {
	background: var(--danger-light);
	color: var(--danger);
	border: 1px solid #fca5a5;
}

/* ── Login ───────────────────────────────────────────────────────── */
.login-page {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #1a56db 0%, #1e40af 100%);
	padding: 24px;
}

.login-card {
	background: white;
	border-radius: 12px;
	padding: 40px;
	width: 100%;
	max-width: 400px;
	box-shadow: var(--shadow-lg);
}

.login-logo {
	text-align: center;
	margin-bottom: 32px;
}
.login-icon {
	font-size: 44px;
}
.login-logo h1 {
	font-size: 22px;
	font-weight: 700;
	color: var(--primary);
	margin-top: 10px;
}
.login-logo p {
	font-size: 13px;
	color: var(--gray-500);
	margin-top: 4px;
}

/* ── Dashboard ───────────────────────────────────────────────────── */
.dashboard-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 24px;
	gap: 16px;
	flex-wrap: wrap;
}

.dashboard-title {
	font-size: 22px;
	font-weight: 700;
	color: var(--gray-900);
	white-space: nowrap;
}

.search-bar {
	display: flex;
	align-items: center;
	background: white;
	border: 1px solid var(--gray-300);
	border-radius: var(--radius);
	padding: 0 12px;
	gap: 8px;
	flex: 1;
	max-width: 480px;
	box-shadow: var(--shadow);
}

.search-bar input {
	border: none;
	outline: none;
	padding: 9px 0;
	font-size: 14px;
	width: 100%;
	color: var(--gray-800);
	background: transparent;
}

.search-bar input::placeholder {
	color: var(--gray-400);
}
.search-icon {
	color: var(--gray-400);
	flex-shrink: 0;
	font-size: 15px;
}

/* ── Sheet Cards ─────────────────────────────────────────────────── */
.sheets-grid {
	display: grid;
	gap: 10px;
}

.sheet-card {
	background: white;
	border: 1px solid var(--gray-200);
	border-radius: var(--radius);
	padding: 14px 18px;
	display: flex;
	align-items: center;
	gap: 14px;
	box-shadow: var(--shadow);
	transition: border-color 0.15s;
}

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

.sheet-type-badge {
	display: inline-flex;
	align-items: center;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
	letter-spacing: 0.03em;
}

.sheet-type-badge.pc {
	background: #dbeafe;
	color: #1d4ed8;
}
.sheet-type-badge.mobil {
	background: #dcfce7;
	color: #15803d;
}

.sheet-info {
	flex: 1;
	min-width: 0;
	cursor: pointer;
}

.sheet-name {
	font-weight: 600;
	color: var(--gray-800);
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sheet-meta {
	font-size: 12px;
	color: var(--gray-500);
	margin-top: 3px;
}

.sheet-actions {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 24px;
	flex-wrap: wrap;
}

.page-title {
	font-size: 20px;
	font-weight: 700;
	color: var(--gray-900);
}

/* ── Section title ───────────────────────────────────────────────── */
.section-title {
	font-size: 14px;
	font-weight: 700;
	color: var(--gray-700);
	margin-bottom: 16px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--gray-200);
}

/* ── Type selector ───────────────────────────────────────────────── */
.type-selector {
	display: flex;
	gap: 14px;
}

.type-option {
	flex: 1;
	border: 2px solid var(--gray-200);
	border-radius: var(--radius);
	padding: 18px 16px;
	cursor: pointer;
	transition: all 0.15s;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	background: white;
}

.type-option:hover {
	border-color: var(--primary);
	background: var(--primary-light);
}
.type-option.selected {
	border-color: var(--primary);
	background: var(--primary-light);
}

.type-icon {
	font-size: 34px;
}
.type-label {
	font-weight: 700;
	font-size: 15px;
	color: var(--gray-700);
}
.type-desc {
	font-size: 12px;
	color: var(--gray-500);
	text-align: center;
}

/* ── Devices table (create) ──────────────────────────────────────── */
.devices-table-wrapper {
	overflow-x: auto;
}

.devices-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.devices-table th {
	background: var(--gray-50);
	padding: 10px 12px;
	text-align: left;
	font-weight: 600;
	color: var(--gray-600);
	border-bottom: 1px solid var(--gray-200);
	white-space: nowrap;
}

.devices-table td {
	padding: 5px 8px;
	border-bottom: 1px solid var(--gray-100);
}

.devices-table tr:last-child td {
	border-bottom: none;
}

.devices-table input {
	width: 100%;
	padding: 5px 8px;
	border: 1px solid var(--gray-200);
	border-radius: 5px;
	font-size: 13px;
	font-family: 'Courier New', monospace;
	color: var(--gray-800);
}

.devices-table input:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

.row-num {
	width: 36px;
	text-align: center;
	color: var(--gray-400);
	font-size: 12px;
}

.remove-btn {
	color: var(--danger) !important;
	padding: 4px 8px !important;
	font-size: 12px !important;
}

.remove-btn:disabled {
	opacity: 0.25 !important;
	cursor: not-allowed !important;
}

/* ── Detail view ─────────────────────────────────────────────────── */
.detail-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 20px;
}

.detail-label {
	font-size: 11px;
	font-weight: 700;
	color: var(--gray-500);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin-bottom: 4px;
}

.detail-value {
	font-size: 15px;
	color: var(--gray-800);
	font-weight: 500;
}

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

.detail-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.detail-table th {
	background: var(--gray-50);
	padding: 10px 14px;
	text-align: left;
	font-weight: 600;
	color: var(--gray-600);
	border-bottom: 2px solid var(--gray-200);
	white-space: nowrap;
}

.detail-table td {
	padding: 9px 14px;
	border-bottom: 1px solid var(--gray-100);
	font-family: 'Courier New', monospace;
	font-size: 12px;
	color: var(--gray-700);
}

.detail-table tr:last-child td {
	border-bottom: none;
}
.detail-table tr:hover td {
	background: var(--gray-50);
}
.row-num-cell {
	text-align: center;
	color: var(--gray-400);
	font-family: sans-serif !important;
}

/* ── Download buttons ────────────────────────────────────────────── */
.download-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
	text-align: center;
	padding: 70px 24px;
	color: var(--gray-500);
}

.empty-icon {
	font-size: 52px;
	margin-bottom: 14px;
}
.empty-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--gray-600);
	margin-bottom: 6px;
}
.empty-desc {
	font-size: 14px;
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.6s linear infinite;
	flex-shrink: 0;
}

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

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 24px;
}

.modal {
	background: white;
	border-radius: 10px;
	padding: 28px;
	max-width: 420px;
	width: 100%;
	box-shadow: var(--shadow-lg);
}

.modal h3 {
	font-size: 17px;
	font-weight: 700;
	color: var(--gray-900);
	margin-bottom: 10px;
}
.modal p {
	font-size: 14px;
	color: var(--gray-600);
	margin-bottom: 22px;
	line-height: 1.6;
}
.modal-actions {
	display: flex;
	gap: 10px;
	justify-content: flex-end;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.main-content {
		padding: 20px 16px;
	}
	.dashboard-top {
		flex-direction: column;
		align-items: stretch;
	}
	.search-bar {
		max-width: none;
	}
	.sheet-card {
		flex-wrap: wrap;
	}
	.sheet-actions {
		width: 100%;
		justify-content: flex-end;
	}
	.type-selector {
		flex-direction: column;
	}
	.page-header {
		flex-direction: column;
	}
	.download-actions {
		width: 100%;
	}
}
